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
|
---|---|---|---|---|---|---|
dries007/TFCSeedMaker
|
src/main/java/net/dries007/tfc/seedmaker/genlayers/LayerIsland.java
|
// Path: src/main/java/net/dries007/tfc/seedmaker/datatypes/Biome.java
// public enum Biome
// {
// OCEAN(0, new Color(0x3232C8)),
// RIVER(1, new Color(0x2B8CBA)),
// BEACH(2, new Color(0xC7A03B)),
// GRAVEL_BEACH(3, new Color(0x7E7450)),
// HIGH_HILLS(4, new Color(0x920072)),
// PLAINS(5, new Color(0x346B25)),
// SWAMPLAND(6, new Color(0x099200)),
// HIGH_HILLS_EDGE(7, new Color(0x92567C)),
// ROLLING_HILLS(8, new Color(0x734B92)),
// MOUNTAINS(9, new Color(0x920000)),
// MOUNTAINS_EDGE(10, new Color(0x924A4C)),
// HIGH_PLAINS(11, new Color(0x225031)),
// DEEP_OCEAN(12, new Color(0x000080)),
// LAKE(13, new Color(0x5D8C8D));
//
// public static final List<Biome> ALLOWEDBIOMES = Arrays.asList(OCEAN, HIGH_HILLS, PLAINS, SWAMPLAND, ROLLING_HILLS, MOUNTAINS, HIGH_PLAINS);
// public static final int[] COLORS = new int[values().length];
//
// static
// {
// for (Biome biome : values()) COLORS[biome.id] = biome.color.getRGB();
// }
//
// public final int id;
// public final Color color;
//
// Biome(final int id, final Color color)
// {
// this.id = id;
// this.color = color;
// }
//
// public static boolean isOceanicBiome(int id)
// {
// return id == OCEAN.id || id == DEEP_OCEAN.id;
// }
//
// public static boolean isWaterBiome(int id)
// {
// return id == OCEAN.id || id == DEEP_OCEAN.id || id == LAKE.id || id == RIVER.id;
// }
//
// public static boolean isMountainBiome(int id)
// {
// return id == MOUNTAINS.id || id == MOUNTAINS_EDGE.id;
// }
//
// public static boolean isBeachBiome(int id)
// {
// return id == BEACH.id || id == GRAVEL_BEACH.id;
// }
// }
|
import net.dries007.tfc.seedmaker.datatypes.Biome;
|
package net.dries007.tfc.seedmaker.genlayers;
public class LayerIsland extends Layer
{
public LayerIsland(final long seed)
{
super(seed);
}
@Override
public int[] getInts(final int x, final int z, final int sizeX, final int sizeZ)
{
final int[] out = new int[sizeX * sizeZ];
for (int zz = 0; zz < sizeZ; ++zz)
{
for (int xx = 0; xx < sizeX; ++xx)
{
initChunkSeed(x + xx, z + zz);
|
// Path: src/main/java/net/dries007/tfc/seedmaker/datatypes/Biome.java
// public enum Biome
// {
// OCEAN(0, new Color(0x3232C8)),
// RIVER(1, new Color(0x2B8CBA)),
// BEACH(2, new Color(0xC7A03B)),
// GRAVEL_BEACH(3, new Color(0x7E7450)),
// HIGH_HILLS(4, new Color(0x920072)),
// PLAINS(5, new Color(0x346B25)),
// SWAMPLAND(6, new Color(0x099200)),
// HIGH_HILLS_EDGE(7, new Color(0x92567C)),
// ROLLING_HILLS(8, new Color(0x734B92)),
// MOUNTAINS(9, new Color(0x920000)),
// MOUNTAINS_EDGE(10, new Color(0x924A4C)),
// HIGH_PLAINS(11, new Color(0x225031)),
// DEEP_OCEAN(12, new Color(0x000080)),
// LAKE(13, new Color(0x5D8C8D));
//
// public static final List<Biome> ALLOWEDBIOMES = Arrays.asList(OCEAN, HIGH_HILLS, PLAINS, SWAMPLAND, ROLLING_HILLS, MOUNTAINS, HIGH_PLAINS);
// public static final int[] COLORS = new int[values().length];
//
// static
// {
// for (Biome biome : values()) COLORS[biome.id] = biome.color.getRGB();
// }
//
// public final int id;
// public final Color color;
//
// Biome(final int id, final Color color)
// {
// this.id = id;
// this.color = color;
// }
//
// public static boolean isOceanicBiome(int id)
// {
// return id == OCEAN.id || id == DEEP_OCEAN.id;
// }
//
// public static boolean isWaterBiome(int id)
// {
// return id == OCEAN.id || id == DEEP_OCEAN.id || id == LAKE.id || id == RIVER.id;
// }
//
// public static boolean isMountainBiome(int id)
// {
// return id == MOUNTAINS.id || id == MOUNTAINS_EDGE.id;
// }
//
// public static boolean isBeachBiome(int id)
// {
// return id == BEACH.id || id == GRAVEL_BEACH.id;
// }
// }
// Path: src/main/java/net/dries007/tfc/seedmaker/genlayers/LayerIsland.java
import net.dries007.tfc.seedmaker.datatypes.Biome;
package net.dries007.tfc.seedmaker.genlayers;
public class LayerIsland extends Layer
{
public LayerIsland(final long seed)
{
super(seed);
}
@Override
public int[] getInts(final int x, final int z, final int sizeX, final int sizeZ)
{
final int[] out = new int[sizeX * sizeZ];
for (int zz = 0; zz < sizeZ; ++zz)
{
for (int xx = 0; xx < sizeX; ++xx)
{
initChunkSeed(x + xx, z + zz);
|
out[xx + zz * sizeX] = nextInt(4) == 0 ? Biome.PLAINS.id : Biome.OCEAN.id;
|
dries007/TFCSeedMaker
|
src/main/java/net/dries007/tfc/seedmaker/genlayers/LayerRockInit.java
|
// Path: src/main/java/net/dries007/tfc/seedmaker/datatypes/Rock.java
// public enum Rock
// {
// GRANITE(0, RockType.IGNEOUS_INTRUSIVE, new Color(0xd3d3d3)),
// DIORITE(1, RockType.IGNEOUS_INTRUSIVE, new Color(0x8b0000)),
// GABBRO(2, RockType.IGNEOUS_INTRUSIVE, new Color(0x808000)),
// SHALE(3, RockType.SEDIMENTARY, new Color(0x008000)),
// CLAYSTONE(4, RockType.SEDIMENTARY, new Color(0x008080)),
// ROCKSALT(5, RockType.SEDIMENTARY, new Color(0x7f007f)),
// LIMESTONE(6, RockType.SEDIMENTARY, new Color(0xff4500)),
// CONGLOMERATE(7, RockType.SEDIMENTARY, new Color(0xffa500)),
// DOLOMITE(8, RockType.SEDIMENTARY, new Color(0xffff00)),
// CHERT(9, RockType.SEDIMENTARY, new Color(0x0000cd)),
// CHALK(10, RockType.SEDIMENTARY, new Color(0x7fff00)),
// RHYOLITE(11, RockType.IGNEOUS_EXTRUSIVE, new Color(0x00ff7f)),
// BASALT(12, RockType.IGNEOUS_EXTRUSIVE, new Color(0x4169e1)),
// ANDESITE(13, RockType.IGNEOUS_EXTRUSIVE, new Color(0x00bfff)),
// DACITE(14, RockType.IGNEOUS_EXTRUSIVE, new Color(0xff00ff)),
// QUARTZITE(15, RockType.METAMORPHIC, new Color(0xdb7093)),
// SLATE(16, RockType.METAMORPHIC, new Color(0xf0e68c)),
// PHYLLITE(17, RockType.METAMORPHIC, new Color(0xff1493)),
// SCHIST(18, RockType.METAMORPHIC, new Color(0xffa07a)),
// GNEISS(19, RockType.METAMORPHIC, new Color(0xee82ee)),
// MARBLE(20, RockType.METAMORPHIC, new Color(0x7fffd4));
//
// public static final Rock[] TOP = Arrays.stream(Rock.values()).filter(x -> x.type.l0).toArray(Rock[]::new);
// public static final Rock[] MIDDLE = Arrays.stream(Rock.values()).filter(x -> x.type.l1).toArray(Rock[]::new);
// public static final Rock[] BOTTOM = Arrays.stream(Rock.values()).filter(x -> x.type.l2).toArray(Rock[]::new);
//
// public static final int[] COLORS = new int[values().length];
//
// static
// {
// for (Rock rock : values()) COLORS[rock.id] = rock.color.getRGB();
// }
//
// public final int id;
// public final RockType type;
// public final Color color;
//
// Rock(int id, RockType type, Color color)
// {
// this.id = id;
// this.type = type;
// this.color = color;
// }
// }
|
import net.dries007.tfc.seedmaker.datatypes.Rock;
|
package net.dries007.tfc.seedmaker.genlayers;
public class LayerRockInit extends Layer
{
|
// Path: src/main/java/net/dries007/tfc/seedmaker/datatypes/Rock.java
// public enum Rock
// {
// GRANITE(0, RockType.IGNEOUS_INTRUSIVE, new Color(0xd3d3d3)),
// DIORITE(1, RockType.IGNEOUS_INTRUSIVE, new Color(0x8b0000)),
// GABBRO(2, RockType.IGNEOUS_INTRUSIVE, new Color(0x808000)),
// SHALE(3, RockType.SEDIMENTARY, new Color(0x008000)),
// CLAYSTONE(4, RockType.SEDIMENTARY, new Color(0x008080)),
// ROCKSALT(5, RockType.SEDIMENTARY, new Color(0x7f007f)),
// LIMESTONE(6, RockType.SEDIMENTARY, new Color(0xff4500)),
// CONGLOMERATE(7, RockType.SEDIMENTARY, new Color(0xffa500)),
// DOLOMITE(8, RockType.SEDIMENTARY, new Color(0xffff00)),
// CHERT(9, RockType.SEDIMENTARY, new Color(0x0000cd)),
// CHALK(10, RockType.SEDIMENTARY, new Color(0x7fff00)),
// RHYOLITE(11, RockType.IGNEOUS_EXTRUSIVE, new Color(0x00ff7f)),
// BASALT(12, RockType.IGNEOUS_EXTRUSIVE, new Color(0x4169e1)),
// ANDESITE(13, RockType.IGNEOUS_EXTRUSIVE, new Color(0x00bfff)),
// DACITE(14, RockType.IGNEOUS_EXTRUSIVE, new Color(0xff00ff)),
// QUARTZITE(15, RockType.METAMORPHIC, new Color(0xdb7093)),
// SLATE(16, RockType.METAMORPHIC, new Color(0xf0e68c)),
// PHYLLITE(17, RockType.METAMORPHIC, new Color(0xff1493)),
// SCHIST(18, RockType.METAMORPHIC, new Color(0xffa07a)),
// GNEISS(19, RockType.METAMORPHIC, new Color(0xee82ee)),
// MARBLE(20, RockType.METAMORPHIC, new Color(0x7fffd4));
//
// public static final Rock[] TOP = Arrays.stream(Rock.values()).filter(x -> x.type.l0).toArray(Rock[]::new);
// public static final Rock[] MIDDLE = Arrays.stream(Rock.values()).filter(x -> x.type.l1).toArray(Rock[]::new);
// public static final Rock[] BOTTOM = Arrays.stream(Rock.values()).filter(x -> x.type.l2).toArray(Rock[]::new);
//
// public static final int[] COLORS = new int[values().length];
//
// static
// {
// for (Rock rock : values()) COLORS[rock.id] = rock.color.getRGB();
// }
//
// public final int id;
// public final RockType type;
// public final Color color;
//
// Rock(int id, RockType type, Color color)
// {
// this.id = id;
// this.type = type;
// this.color = color;
// }
// }
// Path: src/main/java/net/dries007/tfc/seedmaker/genlayers/LayerRockInit.java
import net.dries007.tfc.seedmaker.datatypes.Rock;
package net.dries007.tfc.seedmaker.genlayers;
public class LayerRockInit extends Layer
{
|
final private Rock[] layerRocks;
|
dries007/TFCSeedMaker
|
src/main/java/net/dries007/tfc/seedmaker/genlayers/LayerStabilityInit.java
|
// Path: src/main/java/net/dries007/tfc/seedmaker/datatypes/Stability.java
// public enum Stability
// {
// SEISMIC_STABLE(0, false),
// SEISMIC_UNSTABLE(1, true);
//
// public final int id;
// public final boolean value;
//
// Stability(final int id, final boolean value)
// {
// this.id = id;
// this.value = value;
// }
// }
|
import net.dries007.tfc.seedmaker.datatypes.Stability;
|
package net.dries007.tfc.seedmaker.genlayers;
public class LayerStabilityInit extends Layer
{
public LayerStabilityInit(final long seed)
{
super(seed);
}
@Override
public int[] getInts(final int x, final int y, final int sizeX, final int sizeY)
{
final int[] cache = new int[sizeX * sizeY];
for (int yy = 0; yy < sizeY; ++yy)
{
for (int xx = 0; xx < sizeX; ++xx)
{
this.initChunkSeed(x + xx, y + yy);
|
// Path: src/main/java/net/dries007/tfc/seedmaker/datatypes/Stability.java
// public enum Stability
// {
// SEISMIC_STABLE(0, false),
// SEISMIC_UNSTABLE(1, true);
//
// public final int id;
// public final boolean value;
//
// Stability(final int id, final boolean value)
// {
// this.id = id;
// this.value = value;
// }
// }
// Path: src/main/java/net/dries007/tfc/seedmaker/genlayers/LayerStabilityInit.java
import net.dries007.tfc.seedmaker.datatypes.Stability;
package net.dries007.tfc.seedmaker.genlayers;
public class LayerStabilityInit extends Layer
{
public LayerStabilityInit(final long seed)
{
super(seed);
}
@Override
public int[] getInts(final int x, final int y, final int sizeX, final int sizeY)
{
final int[] cache = new int[sizeX * sizeY];
for (int yy = 0; yy < sizeY; ++yy)
{
for (int xx = 0; xx < sizeX; ++xx)
{
this.initChunkSeed(x + xx, y + yy);
|
cache[xx + yy * sizeX] = this.nextInt(3) == 0 ? Stability.SEISMIC_UNSTABLE.id : Stability.SEISMIC_STABLE.id;
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/PatternValidationStrategies.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlAndCleanPatternSanitizer.java
// public class StripHtmlAndCleanPatternSanitizer extends CleanPatternSanitizer {
//
// private final StripHtmlSanitizer _stripHtmlSanitizer = new StripHtmlSanitizer();
//
// public StripHtmlAndCleanPatternSanitizer(Pattern acceptedPattern) {
// super(acceptedPattern);
// }
//
// public StripHtmlAndCleanPatternSanitizer(String acceptedPattern) {
// super(acceptedPattern);
// }
//
// @Override
// public String execute(String content) {
// String htmlLess = _stripHtmlSanitizer.execute(content);
// return super.execute(htmlLess);
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlSanitizer.java
// public class StripHtmlSanitizer implements Sanitizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Document document = Jsoup.parse(content);
// document.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
// for (Element element : document.select("script,link,iframe,style")) {
// element.remove();
// }
// return document.text();
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/PatternValidator.java
// public class PatternValidator extends Validator<String> {
// public static final int FLAGS = Pattern.DOTALL | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.MULTILINE;
// private final Pattern _pattern;
//
// public PatternValidator(String regex) {
// _pattern = Pattern.compile(regex, FLAGS);
// }
//
// public PatternValidator(Pattern pattern) {
// _pattern = pattern;
// }
//
// @Override
// public boolean execute(String content) {
// return StringUtils.isBlank(content) || _pattern.matcher(content).matches();
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlAndCleanPatternSanitizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlSanitizer;
import com.switchfly.inputvalidation.validator.PatternValidator;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class PatternValidationStrategies implements ValidationStrategies {
private final ValidationStrategy<String> _cleanStrategy;
private final ValidationStrategy<String> _validateStrategy;
public PatternValidationStrategies(String acceptedPattern) {
_cleanStrategy =
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlAndCleanPatternSanitizer.java
// public class StripHtmlAndCleanPatternSanitizer extends CleanPatternSanitizer {
//
// private final StripHtmlSanitizer _stripHtmlSanitizer = new StripHtmlSanitizer();
//
// public StripHtmlAndCleanPatternSanitizer(Pattern acceptedPattern) {
// super(acceptedPattern);
// }
//
// public StripHtmlAndCleanPatternSanitizer(String acceptedPattern) {
// super(acceptedPattern);
// }
//
// @Override
// public String execute(String content) {
// String htmlLess = _stripHtmlSanitizer.execute(content);
// return super.execute(htmlLess);
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlSanitizer.java
// public class StripHtmlSanitizer implements Sanitizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Document document = Jsoup.parse(content);
// document.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
// for (Element element : document.select("script,link,iframe,style")) {
// element.remove();
// }
// return document.text();
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/PatternValidator.java
// public class PatternValidator extends Validator<String> {
// public static final int FLAGS = Pattern.DOTALL | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.MULTILINE;
// private final Pattern _pattern;
//
// public PatternValidator(String regex) {
// _pattern = Pattern.compile(regex, FLAGS);
// }
//
// public PatternValidator(Pattern pattern) {
// _pattern = pattern;
// }
//
// @Override
// public boolean execute(String content) {
// return StringUtils.isBlank(content) || _pattern.matcher(content).matches();
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/PatternValidationStrategies.java
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlAndCleanPatternSanitizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlSanitizer;
import com.switchfly.inputvalidation.validator.PatternValidator;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class PatternValidationStrategies implements ValidationStrategies {
private final ValidationStrategy<String> _cleanStrategy;
private final ValidationStrategy<String> _validateStrategy;
public PatternValidationStrategies(String acceptedPattern) {
_cleanStrategy =
|
new ValidationStrategy<String>(new HtmlAndQueryStringCanonicalizer(), null, new StripHtmlAndCleanPatternSanitizer(acceptedPattern));
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/PatternValidationStrategies.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlAndCleanPatternSanitizer.java
// public class StripHtmlAndCleanPatternSanitizer extends CleanPatternSanitizer {
//
// private final StripHtmlSanitizer _stripHtmlSanitizer = new StripHtmlSanitizer();
//
// public StripHtmlAndCleanPatternSanitizer(Pattern acceptedPattern) {
// super(acceptedPattern);
// }
//
// public StripHtmlAndCleanPatternSanitizer(String acceptedPattern) {
// super(acceptedPattern);
// }
//
// @Override
// public String execute(String content) {
// String htmlLess = _stripHtmlSanitizer.execute(content);
// return super.execute(htmlLess);
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlSanitizer.java
// public class StripHtmlSanitizer implements Sanitizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Document document = Jsoup.parse(content);
// document.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
// for (Element element : document.select("script,link,iframe,style")) {
// element.remove();
// }
// return document.text();
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/PatternValidator.java
// public class PatternValidator extends Validator<String> {
// public static final int FLAGS = Pattern.DOTALL | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.MULTILINE;
// private final Pattern _pattern;
//
// public PatternValidator(String regex) {
// _pattern = Pattern.compile(regex, FLAGS);
// }
//
// public PatternValidator(Pattern pattern) {
// _pattern = pattern;
// }
//
// @Override
// public boolean execute(String content) {
// return StringUtils.isBlank(content) || _pattern.matcher(content).matches();
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlAndCleanPatternSanitizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlSanitizer;
import com.switchfly.inputvalidation.validator.PatternValidator;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class PatternValidationStrategies implements ValidationStrategies {
private final ValidationStrategy<String> _cleanStrategy;
private final ValidationStrategy<String> _validateStrategy;
public PatternValidationStrategies(String acceptedPattern) {
_cleanStrategy =
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlAndCleanPatternSanitizer.java
// public class StripHtmlAndCleanPatternSanitizer extends CleanPatternSanitizer {
//
// private final StripHtmlSanitizer _stripHtmlSanitizer = new StripHtmlSanitizer();
//
// public StripHtmlAndCleanPatternSanitizer(Pattern acceptedPattern) {
// super(acceptedPattern);
// }
//
// public StripHtmlAndCleanPatternSanitizer(String acceptedPattern) {
// super(acceptedPattern);
// }
//
// @Override
// public String execute(String content) {
// String htmlLess = _stripHtmlSanitizer.execute(content);
// return super.execute(htmlLess);
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlSanitizer.java
// public class StripHtmlSanitizer implements Sanitizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Document document = Jsoup.parse(content);
// document.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
// for (Element element : document.select("script,link,iframe,style")) {
// element.remove();
// }
// return document.text();
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/PatternValidator.java
// public class PatternValidator extends Validator<String> {
// public static final int FLAGS = Pattern.DOTALL | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.MULTILINE;
// private final Pattern _pattern;
//
// public PatternValidator(String regex) {
// _pattern = Pattern.compile(regex, FLAGS);
// }
//
// public PatternValidator(Pattern pattern) {
// _pattern = pattern;
// }
//
// @Override
// public boolean execute(String content) {
// return StringUtils.isBlank(content) || _pattern.matcher(content).matches();
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/PatternValidationStrategies.java
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlAndCleanPatternSanitizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlSanitizer;
import com.switchfly.inputvalidation.validator.PatternValidator;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class PatternValidationStrategies implements ValidationStrategies {
private final ValidationStrategy<String> _cleanStrategy;
private final ValidationStrategy<String> _validateStrategy;
public PatternValidationStrategies(String acceptedPattern) {
_cleanStrategy =
|
new ValidationStrategy<String>(new HtmlAndQueryStringCanonicalizer(), null, new StripHtmlAndCleanPatternSanitizer(acceptedPattern));
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/PatternValidationStrategies.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlAndCleanPatternSanitizer.java
// public class StripHtmlAndCleanPatternSanitizer extends CleanPatternSanitizer {
//
// private final StripHtmlSanitizer _stripHtmlSanitizer = new StripHtmlSanitizer();
//
// public StripHtmlAndCleanPatternSanitizer(Pattern acceptedPattern) {
// super(acceptedPattern);
// }
//
// public StripHtmlAndCleanPatternSanitizer(String acceptedPattern) {
// super(acceptedPattern);
// }
//
// @Override
// public String execute(String content) {
// String htmlLess = _stripHtmlSanitizer.execute(content);
// return super.execute(htmlLess);
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlSanitizer.java
// public class StripHtmlSanitizer implements Sanitizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Document document = Jsoup.parse(content);
// document.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
// for (Element element : document.select("script,link,iframe,style")) {
// element.remove();
// }
// return document.text();
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/PatternValidator.java
// public class PatternValidator extends Validator<String> {
// public static final int FLAGS = Pattern.DOTALL | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.MULTILINE;
// private final Pattern _pattern;
//
// public PatternValidator(String regex) {
// _pattern = Pattern.compile(regex, FLAGS);
// }
//
// public PatternValidator(Pattern pattern) {
// _pattern = pattern;
// }
//
// @Override
// public boolean execute(String content) {
// return StringUtils.isBlank(content) || _pattern.matcher(content).matches();
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlAndCleanPatternSanitizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlSanitizer;
import com.switchfly.inputvalidation.validator.PatternValidator;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class PatternValidationStrategies implements ValidationStrategies {
private final ValidationStrategy<String> _cleanStrategy;
private final ValidationStrategy<String> _validateStrategy;
public PatternValidationStrategies(String acceptedPattern) {
_cleanStrategy =
new ValidationStrategy<String>(new HtmlAndQueryStringCanonicalizer(), null, new StripHtmlAndCleanPatternSanitizer(acceptedPattern));
_validateStrategy =
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlAndCleanPatternSanitizer.java
// public class StripHtmlAndCleanPatternSanitizer extends CleanPatternSanitizer {
//
// private final StripHtmlSanitizer _stripHtmlSanitizer = new StripHtmlSanitizer();
//
// public StripHtmlAndCleanPatternSanitizer(Pattern acceptedPattern) {
// super(acceptedPattern);
// }
//
// public StripHtmlAndCleanPatternSanitizer(String acceptedPattern) {
// super(acceptedPattern);
// }
//
// @Override
// public String execute(String content) {
// String htmlLess = _stripHtmlSanitizer.execute(content);
// return super.execute(htmlLess);
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlSanitizer.java
// public class StripHtmlSanitizer implements Sanitizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Document document = Jsoup.parse(content);
// document.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
// for (Element element : document.select("script,link,iframe,style")) {
// element.remove();
// }
// return document.text();
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/PatternValidator.java
// public class PatternValidator extends Validator<String> {
// public static final int FLAGS = Pattern.DOTALL | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.MULTILINE;
// private final Pattern _pattern;
//
// public PatternValidator(String regex) {
// _pattern = Pattern.compile(regex, FLAGS);
// }
//
// public PatternValidator(Pattern pattern) {
// _pattern = pattern;
// }
//
// @Override
// public boolean execute(String content) {
// return StringUtils.isBlank(content) || _pattern.matcher(content).matches();
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/PatternValidationStrategies.java
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlAndCleanPatternSanitizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlSanitizer;
import com.switchfly.inputvalidation.validator.PatternValidator;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class PatternValidationStrategies implements ValidationStrategies {
private final ValidationStrategy<String> _cleanStrategy;
private final ValidationStrategy<String> _validateStrategy;
public PatternValidationStrategies(String acceptedPattern) {
_cleanStrategy =
new ValidationStrategy<String>(new HtmlAndQueryStringCanonicalizer(), null, new StripHtmlAndCleanPatternSanitizer(acceptedPattern));
_validateStrategy =
|
new ValidationStrategy<String>(new HtmlAndQueryStringCanonicalizer(), new PatternValidator(acceptedPattern), new StripHtmlSanitizer());
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/PatternValidationStrategies.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlAndCleanPatternSanitizer.java
// public class StripHtmlAndCleanPatternSanitizer extends CleanPatternSanitizer {
//
// private final StripHtmlSanitizer _stripHtmlSanitizer = new StripHtmlSanitizer();
//
// public StripHtmlAndCleanPatternSanitizer(Pattern acceptedPattern) {
// super(acceptedPattern);
// }
//
// public StripHtmlAndCleanPatternSanitizer(String acceptedPattern) {
// super(acceptedPattern);
// }
//
// @Override
// public String execute(String content) {
// String htmlLess = _stripHtmlSanitizer.execute(content);
// return super.execute(htmlLess);
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlSanitizer.java
// public class StripHtmlSanitizer implements Sanitizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Document document = Jsoup.parse(content);
// document.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
// for (Element element : document.select("script,link,iframe,style")) {
// element.remove();
// }
// return document.text();
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/PatternValidator.java
// public class PatternValidator extends Validator<String> {
// public static final int FLAGS = Pattern.DOTALL | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.MULTILINE;
// private final Pattern _pattern;
//
// public PatternValidator(String regex) {
// _pattern = Pattern.compile(regex, FLAGS);
// }
//
// public PatternValidator(Pattern pattern) {
// _pattern = pattern;
// }
//
// @Override
// public boolean execute(String content) {
// return StringUtils.isBlank(content) || _pattern.matcher(content).matches();
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlAndCleanPatternSanitizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlSanitizer;
import com.switchfly.inputvalidation.validator.PatternValidator;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class PatternValidationStrategies implements ValidationStrategies {
private final ValidationStrategy<String> _cleanStrategy;
private final ValidationStrategy<String> _validateStrategy;
public PatternValidationStrategies(String acceptedPattern) {
_cleanStrategy =
new ValidationStrategy<String>(new HtmlAndQueryStringCanonicalizer(), null, new StripHtmlAndCleanPatternSanitizer(acceptedPattern));
_validateStrategy =
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlAndCleanPatternSanitizer.java
// public class StripHtmlAndCleanPatternSanitizer extends CleanPatternSanitizer {
//
// private final StripHtmlSanitizer _stripHtmlSanitizer = new StripHtmlSanitizer();
//
// public StripHtmlAndCleanPatternSanitizer(Pattern acceptedPattern) {
// super(acceptedPattern);
// }
//
// public StripHtmlAndCleanPatternSanitizer(String acceptedPattern) {
// super(acceptedPattern);
// }
//
// @Override
// public String execute(String content) {
// String htmlLess = _stripHtmlSanitizer.execute(content);
// return super.execute(htmlLess);
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlSanitizer.java
// public class StripHtmlSanitizer implements Sanitizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Document document = Jsoup.parse(content);
// document.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
// for (Element element : document.select("script,link,iframe,style")) {
// element.remove();
// }
// return document.text();
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/PatternValidator.java
// public class PatternValidator extends Validator<String> {
// public static final int FLAGS = Pattern.DOTALL | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.MULTILINE;
// private final Pattern _pattern;
//
// public PatternValidator(String regex) {
// _pattern = Pattern.compile(regex, FLAGS);
// }
//
// public PatternValidator(Pattern pattern) {
// _pattern = pattern;
// }
//
// @Override
// public boolean execute(String content) {
// return StringUtils.isBlank(content) || _pattern.matcher(content).matches();
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/PatternValidationStrategies.java
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlAndCleanPatternSanitizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlSanitizer;
import com.switchfly.inputvalidation.validator.PatternValidator;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class PatternValidationStrategies implements ValidationStrategies {
private final ValidationStrategy<String> _cleanStrategy;
private final ValidationStrategy<String> _validateStrategy;
public PatternValidationStrategies(String acceptedPattern) {
_cleanStrategy =
new ValidationStrategy<String>(new HtmlAndQueryStringCanonicalizer(), null, new StripHtmlAndCleanPatternSanitizer(acceptedPattern));
_validateStrategy =
|
new ValidationStrategy<String>(new HtmlAndQueryStringCanonicalizer(), new PatternValidator(acceptedPattern), new StripHtmlSanitizer());
|
switchfly/switchfly-java
|
compress/src/main/java/com/switchfly/compress/cli/CompressCLI.java
|
// Path: compress/src/main/java/com/switchfly/compress/cli/configuration/IConfiguration.java
// public interface IConfiguration {
//
// void loadFile(String path) throws IOException;
//
// void loadDocument(String document);
//
// void loadStream(InputStream stream);
//
// Set<String> getJsPackages();
//
// Set<String> getCSSPackages();
//
// List<String> getFilesForJsPackage(String jsPackage);
//
// List<String> getFilesForCssPackage(String cssPackage);
// }
//
// Path: compress/src/main/java/com/switchfly/compress/cli/configuration/YamlConfiguration.java
// public class YamlConfiguration implements IConfiguration {
//
// private Map<String, List<String>> _cssMap = new HashMap<String, List<String>>();
// private Map<String, List<String>> _jsMap = new HashMap<String, List<String>>();
//
// @Override
// public Set<String> getCSSPackages() {
// return _cssMap.keySet();
// }
//
// @Override
// public List<String> getFilesForCssPackage(String cssPackage) {
// if (_cssMap.containsKey(cssPackage)) {
// return _cssMap.get(cssPackage);
// }
// return Collections.emptyList();
// }
//
// @Override
// public Set<String> getJsPackages() {
// return _jsMap.keySet();
// }
//
// @Override
// public List<String> getFilesForJsPackage(String jsPackage) {
// if (_jsMap.containsKey(jsPackage)) {
// return _jsMap.get(jsPackage);
// }
// return Collections.emptyList();
// }
//
// @Override
// public void loadFile(String path) throws IOException {
// InputStream input = null;
// try {
// input = new FileInputStream(new File(path));
// loadStream(input);
// } finally {
// if (input != null) {
// input.close();
// }
// }
// }
//
// @Override
// public void loadDocument(String document) {
// Yaml yaml = new Yaml();
// processData(yaml.load(document));
// }
//
// @Override
// public void loadStream(InputStream stream) {
// Yaml yaml = new Yaml();
// processData(yaml.load(stream));
// }
//
// private boolean isDocumentValid(Object document) {
// if (!(document instanceof Map)) {
// return false;
// }
//
// //NOTE: we dont attempt to resolve element types. If file format is not as expected we let the app blow up
// return true;
// }
//
// @SuppressWarnings("unchecked")
// private void processData(Object document) {
//
// if (!isDocumentValid(document)) {
// return;
// }
//
// Map<String, List<LinkedHashMap<String, Vector<String>>>> data = (Map<String, List<LinkedHashMap<String, Vector<String>>>>) document;
//
// if (data.containsKey("javascript")) {
// populateFileMapFromStructure(_jsMap, data.get("javascript"), ".js");
// }
//
// if (data.containsKey("stylesheet")) {
// populateFileMapFromStructure(_cssMap, data.get("stylesheet"), ".css");
// }
// }
//
// private void populateFileMapFromStructure(Map<String, List<String>> map, List<LinkedHashMap<String, Vector<String>>> value,
// String fileExtension) {
//
// for (LinkedHashMap<String, Vector<String>> fileSet : value) {
// for (String key : fileSet.keySet()) {
// ArrayList<String> files = new ArrayList<String>();
// List<String> valueFiles = fileSet.get(key);
// for (String aFile : valueFiles) {
// files.add(aFile + fileExtension);
// }
// map.put(key, files);
// }
// }
// }
// }
//
// Path: compress/src/main/java/com/switchfly/compress/cli/exceptions/CompressorException.java
// @SuppressWarnings("serial")
// public class CompressorException extends Exception {
//
// public CompressorException(String message) {
// super(message);
// }
// }
|
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.List;
import java.util.Set;
import com.switchfly.compress.cli.configuration.IConfiguration;
import com.switchfly.compress.cli.configuration.YamlConfiguration;
import com.switchfly.compress.cli.exceptions.CompressorException;
import com.yahoo.platform.yui.compressor.CssCompressor;
import com.yahoo.platform.yui.compressor.JavaScriptCompressor;
import jargs.gnu.CmdLineParser;
import org.mozilla.javascript.ErrorReporter;
import org.mozilla.javascript.EvaluatorException;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.compress.cli;
/* Usage of this tool is:
-y ${PROJ.JS_COMMON_SRC}/asset_packages.yml : configuration
-o ${PROJ.JS_COMMON_TARGET}/packages : output location
-i ${PROJ.JS_COMMON_SRC}/ : input location (to resolve contents of yml)
-u ${js_common_assets_url} : the JS URI fragment (/js)
-c ${js_common_assets_url} : the CSS URI fragment (/css)
-L : include for Package(List-only). Leave out for compression
*/
public class CompressCLI {
private String _baseInputPath;
|
// Path: compress/src/main/java/com/switchfly/compress/cli/configuration/IConfiguration.java
// public interface IConfiguration {
//
// void loadFile(String path) throws IOException;
//
// void loadDocument(String document);
//
// void loadStream(InputStream stream);
//
// Set<String> getJsPackages();
//
// Set<String> getCSSPackages();
//
// List<String> getFilesForJsPackage(String jsPackage);
//
// List<String> getFilesForCssPackage(String cssPackage);
// }
//
// Path: compress/src/main/java/com/switchfly/compress/cli/configuration/YamlConfiguration.java
// public class YamlConfiguration implements IConfiguration {
//
// private Map<String, List<String>> _cssMap = new HashMap<String, List<String>>();
// private Map<String, List<String>> _jsMap = new HashMap<String, List<String>>();
//
// @Override
// public Set<String> getCSSPackages() {
// return _cssMap.keySet();
// }
//
// @Override
// public List<String> getFilesForCssPackage(String cssPackage) {
// if (_cssMap.containsKey(cssPackage)) {
// return _cssMap.get(cssPackage);
// }
// return Collections.emptyList();
// }
//
// @Override
// public Set<String> getJsPackages() {
// return _jsMap.keySet();
// }
//
// @Override
// public List<String> getFilesForJsPackage(String jsPackage) {
// if (_jsMap.containsKey(jsPackage)) {
// return _jsMap.get(jsPackage);
// }
// return Collections.emptyList();
// }
//
// @Override
// public void loadFile(String path) throws IOException {
// InputStream input = null;
// try {
// input = new FileInputStream(new File(path));
// loadStream(input);
// } finally {
// if (input != null) {
// input.close();
// }
// }
// }
//
// @Override
// public void loadDocument(String document) {
// Yaml yaml = new Yaml();
// processData(yaml.load(document));
// }
//
// @Override
// public void loadStream(InputStream stream) {
// Yaml yaml = new Yaml();
// processData(yaml.load(stream));
// }
//
// private boolean isDocumentValid(Object document) {
// if (!(document instanceof Map)) {
// return false;
// }
//
// //NOTE: we dont attempt to resolve element types. If file format is not as expected we let the app blow up
// return true;
// }
//
// @SuppressWarnings("unchecked")
// private void processData(Object document) {
//
// if (!isDocumentValid(document)) {
// return;
// }
//
// Map<String, List<LinkedHashMap<String, Vector<String>>>> data = (Map<String, List<LinkedHashMap<String, Vector<String>>>>) document;
//
// if (data.containsKey("javascript")) {
// populateFileMapFromStructure(_jsMap, data.get("javascript"), ".js");
// }
//
// if (data.containsKey("stylesheet")) {
// populateFileMapFromStructure(_cssMap, data.get("stylesheet"), ".css");
// }
// }
//
// private void populateFileMapFromStructure(Map<String, List<String>> map, List<LinkedHashMap<String, Vector<String>>> value,
// String fileExtension) {
//
// for (LinkedHashMap<String, Vector<String>> fileSet : value) {
// for (String key : fileSet.keySet()) {
// ArrayList<String> files = new ArrayList<String>();
// List<String> valueFiles = fileSet.get(key);
// for (String aFile : valueFiles) {
// files.add(aFile + fileExtension);
// }
// map.put(key, files);
// }
// }
// }
// }
//
// Path: compress/src/main/java/com/switchfly/compress/cli/exceptions/CompressorException.java
// @SuppressWarnings("serial")
// public class CompressorException extends Exception {
//
// public CompressorException(String message) {
// super(message);
// }
// }
// Path: compress/src/main/java/com/switchfly/compress/cli/CompressCLI.java
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.List;
import java.util.Set;
import com.switchfly.compress.cli.configuration.IConfiguration;
import com.switchfly.compress.cli.configuration.YamlConfiguration;
import com.switchfly.compress.cli.exceptions.CompressorException;
import com.yahoo.platform.yui.compressor.CssCompressor;
import com.yahoo.platform.yui.compressor.JavaScriptCompressor;
import jargs.gnu.CmdLineParser;
import org.mozilla.javascript.ErrorReporter;
import org.mozilla.javascript.EvaluatorException;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.compress.cli;
/* Usage of this tool is:
-y ${PROJ.JS_COMMON_SRC}/asset_packages.yml : configuration
-o ${PROJ.JS_COMMON_TARGET}/packages : output location
-i ${PROJ.JS_COMMON_SRC}/ : input location (to resolve contents of yml)
-u ${js_common_assets_url} : the JS URI fragment (/js)
-c ${js_common_assets_url} : the CSS URI fragment (/css)
-L : include for Package(List-only). Leave out for compression
*/
public class CompressCLI {
private String _baseInputPath;
|
private IConfiguration _config;
|
switchfly/switchfly-java
|
compress/src/main/java/com/switchfly/compress/cli/CompressCLI.java
|
// Path: compress/src/main/java/com/switchfly/compress/cli/configuration/IConfiguration.java
// public interface IConfiguration {
//
// void loadFile(String path) throws IOException;
//
// void loadDocument(String document);
//
// void loadStream(InputStream stream);
//
// Set<String> getJsPackages();
//
// Set<String> getCSSPackages();
//
// List<String> getFilesForJsPackage(String jsPackage);
//
// List<String> getFilesForCssPackage(String cssPackage);
// }
//
// Path: compress/src/main/java/com/switchfly/compress/cli/configuration/YamlConfiguration.java
// public class YamlConfiguration implements IConfiguration {
//
// private Map<String, List<String>> _cssMap = new HashMap<String, List<String>>();
// private Map<String, List<String>> _jsMap = new HashMap<String, List<String>>();
//
// @Override
// public Set<String> getCSSPackages() {
// return _cssMap.keySet();
// }
//
// @Override
// public List<String> getFilesForCssPackage(String cssPackage) {
// if (_cssMap.containsKey(cssPackage)) {
// return _cssMap.get(cssPackage);
// }
// return Collections.emptyList();
// }
//
// @Override
// public Set<String> getJsPackages() {
// return _jsMap.keySet();
// }
//
// @Override
// public List<String> getFilesForJsPackage(String jsPackage) {
// if (_jsMap.containsKey(jsPackage)) {
// return _jsMap.get(jsPackage);
// }
// return Collections.emptyList();
// }
//
// @Override
// public void loadFile(String path) throws IOException {
// InputStream input = null;
// try {
// input = new FileInputStream(new File(path));
// loadStream(input);
// } finally {
// if (input != null) {
// input.close();
// }
// }
// }
//
// @Override
// public void loadDocument(String document) {
// Yaml yaml = new Yaml();
// processData(yaml.load(document));
// }
//
// @Override
// public void loadStream(InputStream stream) {
// Yaml yaml = new Yaml();
// processData(yaml.load(stream));
// }
//
// private boolean isDocumentValid(Object document) {
// if (!(document instanceof Map)) {
// return false;
// }
//
// //NOTE: we dont attempt to resolve element types. If file format is not as expected we let the app blow up
// return true;
// }
//
// @SuppressWarnings("unchecked")
// private void processData(Object document) {
//
// if (!isDocumentValid(document)) {
// return;
// }
//
// Map<String, List<LinkedHashMap<String, Vector<String>>>> data = (Map<String, List<LinkedHashMap<String, Vector<String>>>>) document;
//
// if (data.containsKey("javascript")) {
// populateFileMapFromStructure(_jsMap, data.get("javascript"), ".js");
// }
//
// if (data.containsKey("stylesheet")) {
// populateFileMapFromStructure(_cssMap, data.get("stylesheet"), ".css");
// }
// }
//
// private void populateFileMapFromStructure(Map<String, List<String>> map, List<LinkedHashMap<String, Vector<String>>> value,
// String fileExtension) {
//
// for (LinkedHashMap<String, Vector<String>> fileSet : value) {
// for (String key : fileSet.keySet()) {
// ArrayList<String> files = new ArrayList<String>();
// List<String> valueFiles = fileSet.get(key);
// for (String aFile : valueFiles) {
// files.add(aFile + fileExtension);
// }
// map.put(key, files);
// }
// }
// }
// }
//
// Path: compress/src/main/java/com/switchfly/compress/cli/exceptions/CompressorException.java
// @SuppressWarnings("serial")
// public class CompressorException extends Exception {
//
// public CompressorException(String message) {
// super(message);
// }
// }
|
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.List;
import java.util.Set;
import com.switchfly.compress.cli.configuration.IConfiguration;
import com.switchfly.compress.cli.configuration.YamlConfiguration;
import com.switchfly.compress.cli.exceptions.CompressorException;
import com.yahoo.platform.yui.compressor.CssCompressor;
import com.yahoo.platform.yui.compressor.JavaScriptCompressor;
import jargs.gnu.CmdLineParser;
import org.mozilla.javascript.ErrorReporter;
import org.mozilla.javascript.EvaluatorException;
|
}
public void setIsVerbose(boolean isVerbose) {
this._isVerbose = isVerbose;
}
public void setIsDebug(boolean isDebug) {
this._isDebug = isDebug;
}
public void setLineBreakPos(int breakPos) {
_lineBreakPos = breakPos;
}
public void setObfuscate(boolean obfuscate) {
_obfuscate = obfuscate;
}
public void setDisableMicroOptimizations(boolean disableMicroOptimizations) {
_disableMicroOptimizations = disableMicroOptimizations;
}
public void setPreserveUnecessarySemicolons(boolean preserveUnecessarySemicolons) {
_preserveUnecessarySemicolons = preserveUnecessarySemicolons;
}
public void setOutputPath(String outputPath) {
_outputPath = outputPath;
}
|
// Path: compress/src/main/java/com/switchfly/compress/cli/configuration/IConfiguration.java
// public interface IConfiguration {
//
// void loadFile(String path) throws IOException;
//
// void loadDocument(String document);
//
// void loadStream(InputStream stream);
//
// Set<String> getJsPackages();
//
// Set<String> getCSSPackages();
//
// List<String> getFilesForJsPackage(String jsPackage);
//
// List<String> getFilesForCssPackage(String cssPackage);
// }
//
// Path: compress/src/main/java/com/switchfly/compress/cli/configuration/YamlConfiguration.java
// public class YamlConfiguration implements IConfiguration {
//
// private Map<String, List<String>> _cssMap = new HashMap<String, List<String>>();
// private Map<String, List<String>> _jsMap = new HashMap<String, List<String>>();
//
// @Override
// public Set<String> getCSSPackages() {
// return _cssMap.keySet();
// }
//
// @Override
// public List<String> getFilesForCssPackage(String cssPackage) {
// if (_cssMap.containsKey(cssPackage)) {
// return _cssMap.get(cssPackage);
// }
// return Collections.emptyList();
// }
//
// @Override
// public Set<String> getJsPackages() {
// return _jsMap.keySet();
// }
//
// @Override
// public List<String> getFilesForJsPackage(String jsPackage) {
// if (_jsMap.containsKey(jsPackage)) {
// return _jsMap.get(jsPackage);
// }
// return Collections.emptyList();
// }
//
// @Override
// public void loadFile(String path) throws IOException {
// InputStream input = null;
// try {
// input = new FileInputStream(new File(path));
// loadStream(input);
// } finally {
// if (input != null) {
// input.close();
// }
// }
// }
//
// @Override
// public void loadDocument(String document) {
// Yaml yaml = new Yaml();
// processData(yaml.load(document));
// }
//
// @Override
// public void loadStream(InputStream stream) {
// Yaml yaml = new Yaml();
// processData(yaml.load(stream));
// }
//
// private boolean isDocumentValid(Object document) {
// if (!(document instanceof Map)) {
// return false;
// }
//
// //NOTE: we dont attempt to resolve element types. If file format is not as expected we let the app blow up
// return true;
// }
//
// @SuppressWarnings("unchecked")
// private void processData(Object document) {
//
// if (!isDocumentValid(document)) {
// return;
// }
//
// Map<String, List<LinkedHashMap<String, Vector<String>>>> data = (Map<String, List<LinkedHashMap<String, Vector<String>>>>) document;
//
// if (data.containsKey("javascript")) {
// populateFileMapFromStructure(_jsMap, data.get("javascript"), ".js");
// }
//
// if (data.containsKey("stylesheet")) {
// populateFileMapFromStructure(_cssMap, data.get("stylesheet"), ".css");
// }
// }
//
// private void populateFileMapFromStructure(Map<String, List<String>> map, List<LinkedHashMap<String, Vector<String>>> value,
// String fileExtension) {
//
// for (LinkedHashMap<String, Vector<String>> fileSet : value) {
// for (String key : fileSet.keySet()) {
// ArrayList<String> files = new ArrayList<String>();
// List<String> valueFiles = fileSet.get(key);
// for (String aFile : valueFiles) {
// files.add(aFile + fileExtension);
// }
// map.put(key, files);
// }
// }
// }
// }
//
// Path: compress/src/main/java/com/switchfly/compress/cli/exceptions/CompressorException.java
// @SuppressWarnings("serial")
// public class CompressorException extends Exception {
//
// public CompressorException(String message) {
// super(message);
// }
// }
// Path: compress/src/main/java/com/switchfly/compress/cli/CompressCLI.java
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.List;
import java.util.Set;
import com.switchfly.compress.cli.configuration.IConfiguration;
import com.switchfly.compress.cli.configuration.YamlConfiguration;
import com.switchfly.compress.cli.exceptions.CompressorException;
import com.yahoo.platform.yui.compressor.CssCompressor;
import com.yahoo.platform.yui.compressor.JavaScriptCompressor;
import jargs.gnu.CmdLineParser;
import org.mozilla.javascript.ErrorReporter;
import org.mozilla.javascript.EvaluatorException;
}
public void setIsVerbose(boolean isVerbose) {
this._isVerbose = isVerbose;
}
public void setIsDebug(boolean isDebug) {
this._isDebug = isDebug;
}
public void setLineBreakPos(int breakPos) {
_lineBreakPos = breakPos;
}
public void setObfuscate(boolean obfuscate) {
_obfuscate = obfuscate;
}
public void setDisableMicroOptimizations(boolean disableMicroOptimizations) {
_disableMicroOptimizations = disableMicroOptimizations;
}
public void setPreserveUnecessarySemicolons(boolean preserveUnecessarySemicolons) {
_preserveUnecessarySemicolons = preserveUnecessarySemicolons;
}
public void setOutputPath(String outputPath) {
_outputPath = outputPath;
}
|
public void setConfigurationFromFile(String configurationPath) throws CompressorException, IOException {
|
switchfly/switchfly-java
|
compress/src/main/java/com/switchfly/compress/cli/CompressCLI.java
|
// Path: compress/src/main/java/com/switchfly/compress/cli/configuration/IConfiguration.java
// public interface IConfiguration {
//
// void loadFile(String path) throws IOException;
//
// void loadDocument(String document);
//
// void loadStream(InputStream stream);
//
// Set<String> getJsPackages();
//
// Set<String> getCSSPackages();
//
// List<String> getFilesForJsPackage(String jsPackage);
//
// List<String> getFilesForCssPackage(String cssPackage);
// }
//
// Path: compress/src/main/java/com/switchfly/compress/cli/configuration/YamlConfiguration.java
// public class YamlConfiguration implements IConfiguration {
//
// private Map<String, List<String>> _cssMap = new HashMap<String, List<String>>();
// private Map<String, List<String>> _jsMap = new HashMap<String, List<String>>();
//
// @Override
// public Set<String> getCSSPackages() {
// return _cssMap.keySet();
// }
//
// @Override
// public List<String> getFilesForCssPackage(String cssPackage) {
// if (_cssMap.containsKey(cssPackage)) {
// return _cssMap.get(cssPackage);
// }
// return Collections.emptyList();
// }
//
// @Override
// public Set<String> getJsPackages() {
// return _jsMap.keySet();
// }
//
// @Override
// public List<String> getFilesForJsPackage(String jsPackage) {
// if (_jsMap.containsKey(jsPackage)) {
// return _jsMap.get(jsPackage);
// }
// return Collections.emptyList();
// }
//
// @Override
// public void loadFile(String path) throws IOException {
// InputStream input = null;
// try {
// input = new FileInputStream(new File(path));
// loadStream(input);
// } finally {
// if (input != null) {
// input.close();
// }
// }
// }
//
// @Override
// public void loadDocument(String document) {
// Yaml yaml = new Yaml();
// processData(yaml.load(document));
// }
//
// @Override
// public void loadStream(InputStream stream) {
// Yaml yaml = new Yaml();
// processData(yaml.load(stream));
// }
//
// private boolean isDocumentValid(Object document) {
// if (!(document instanceof Map)) {
// return false;
// }
//
// //NOTE: we dont attempt to resolve element types. If file format is not as expected we let the app blow up
// return true;
// }
//
// @SuppressWarnings("unchecked")
// private void processData(Object document) {
//
// if (!isDocumentValid(document)) {
// return;
// }
//
// Map<String, List<LinkedHashMap<String, Vector<String>>>> data = (Map<String, List<LinkedHashMap<String, Vector<String>>>>) document;
//
// if (data.containsKey("javascript")) {
// populateFileMapFromStructure(_jsMap, data.get("javascript"), ".js");
// }
//
// if (data.containsKey("stylesheet")) {
// populateFileMapFromStructure(_cssMap, data.get("stylesheet"), ".css");
// }
// }
//
// private void populateFileMapFromStructure(Map<String, List<String>> map, List<LinkedHashMap<String, Vector<String>>> value,
// String fileExtension) {
//
// for (LinkedHashMap<String, Vector<String>> fileSet : value) {
// for (String key : fileSet.keySet()) {
// ArrayList<String> files = new ArrayList<String>();
// List<String> valueFiles = fileSet.get(key);
// for (String aFile : valueFiles) {
// files.add(aFile + fileExtension);
// }
// map.put(key, files);
// }
// }
// }
// }
//
// Path: compress/src/main/java/com/switchfly/compress/cli/exceptions/CompressorException.java
// @SuppressWarnings("serial")
// public class CompressorException extends Exception {
//
// public CompressorException(String message) {
// super(message);
// }
// }
|
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.List;
import java.util.Set;
import com.switchfly.compress.cli.configuration.IConfiguration;
import com.switchfly.compress.cli.configuration.YamlConfiguration;
import com.switchfly.compress.cli.exceptions.CompressorException;
import com.yahoo.platform.yui.compressor.CssCompressor;
import com.yahoo.platform.yui.compressor.JavaScriptCompressor;
import jargs.gnu.CmdLineParser;
import org.mozilla.javascript.ErrorReporter;
import org.mozilla.javascript.EvaluatorException;
|
public void setIsVerbose(boolean isVerbose) {
this._isVerbose = isVerbose;
}
public void setIsDebug(boolean isDebug) {
this._isDebug = isDebug;
}
public void setLineBreakPos(int breakPos) {
_lineBreakPos = breakPos;
}
public void setObfuscate(boolean obfuscate) {
_obfuscate = obfuscate;
}
public void setDisableMicroOptimizations(boolean disableMicroOptimizations) {
_disableMicroOptimizations = disableMicroOptimizations;
}
public void setPreserveUnecessarySemicolons(boolean preserveUnecessarySemicolons) {
_preserveUnecessarySemicolons = preserveUnecessarySemicolons;
}
public void setOutputPath(String outputPath) {
_outputPath = outputPath;
}
public void setConfigurationFromFile(String configurationPath) throws CompressorException, IOException {
|
// Path: compress/src/main/java/com/switchfly/compress/cli/configuration/IConfiguration.java
// public interface IConfiguration {
//
// void loadFile(String path) throws IOException;
//
// void loadDocument(String document);
//
// void loadStream(InputStream stream);
//
// Set<String> getJsPackages();
//
// Set<String> getCSSPackages();
//
// List<String> getFilesForJsPackage(String jsPackage);
//
// List<String> getFilesForCssPackage(String cssPackage);
// }
//
// Path: compress/src/main/java/com/switchfly/compress/cli/configuration/YamlConfiguration.java
// public class YamlConfiguration implements IConfiguration {
//
// private Map<String, List<String>> _cssMap = new HashMap<String, List<String>>();
// private Map<String, List<String>> _jsMap = new HashMap<String, List<String>>();
//
// @Override
// public Set<String> getCSSPackages() {
// return _cssMap.keySet();
// }
//
// @Override
// public List<String> getFilesForCssPackage(String cssPackage) {
// if (_cssMap.containsKey(cssPackage)) {
// return _cssMap.get(cssPackage);
// }
// return Collections.emptyList();
// }
//
// @Override
// public Set<String> getJsPackages() {
// return _jsMap.keySet();
// }
//
// @Override
// public List<String> getFilesForJsPackage(String jsPackage) {
// if (_jsMap.containsKey(jsPackage)) {
// return _jsMap.get(jsPackage);
// }
// return Collections.emptyList();
// }
//
// @Override
// public void loadFile(String path) throws IOException {
// InputStream input = null;
// try {
// input = new FileInputStream(new File(path));
// loadStream(input);
// } finally {
// if (input != null) {
// input.close();
// }
// }
// }
//
// @Override
// public void loadDocument(String document) {
// Yaml yaml = new Yaml();
// processData(yaml.load(document));
// }
//
// @Override
// public void loadStream(InputStream stream) {
// Yaml yaml = new Yaml();
// processData(yaml.load(stream));
// }
//
// private boolean isDocumentValid(Object document) {
// if (!(document instanceof Map)) {
// return false;
// }
//
// //NOTE: we dont attempt to resolve element types. If file format is not as expected we let the app blow up
// return true;
// }
//
// @SuppressWarnings("unchecked")
// private void processData(Object document) {
//
// if (!isDocumentValid(document)) {
// return;
// }
//
// Map<String, List<LinkedHashMap<String, Vector<String>>>> data = (Map<String, List<LinkedHashMap<String, Vector<String>>>>) document;
//
// if (data.containsKey("javascript")) {
// populateFileMapFromStructure(_jsMap, data.get("javascript"), ".js");
// }
//
// if (data.containsKey("stylesheet")) {
// populateFileMapFromStructure(_cssMap, data.get("stylesheet"), ".css");
// }
// }
//
// private void populateFileMapFromStructure(Map<String, List<String>> map, List<LinkedHashMap<String, Vector<String>>> value,
// String fileExtension) {
//
// for (LinkedHashMap<String, Vector<String>> fileSet : value) {
// for (String key : fileSet.keySet()) {
// ArrayList<String> files = new ArrayList<String>();
// List<String> valueFiles = fileSet.get(key);
// for (String aFile : valueFiles) {
// files.add(aFile + fileExtension);
// }
// map.put(key, files);
// }
// }
// }
// }
//
// Path: compress/src/main/java/com/switchfly/compress/cli/exceptions/CompressorException.java
// @SuppressWarnings("serial")
// public class CompressorException extends Exception {
//
// public CompressorException(String message) {
// super(message);
// }
// }
// Path: compress/src/main/java/com/switchfly/compress/cli/CompressCLI.java
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.List;
import java.util.Set;
import com.switchfly.compress.cli.configuration.IConfiguration;
import com.switchfly.compress.cli.configuration.YamlConfiguration;
import com.switchfly.compress.cli.exceptions.CompressorException;
import com.yahoo.platform.yui.compressor.CssCompressor;
import com.yahoo.platform.yui.compressor.JavaScriptCompressor;
import jargs.gnu.CmdLineParser;
import org.mozilla.javascript.ErrorReporter;
import org.mozilla.javascript.EvaluatorException;
public void setIsVerbose(boolean isVerbose) {
this._isVerbose = isVerbose;
}
public void setIsDebug(boolean isDebug) {
this._isDebug = isDebug;
}
public void setLineBreakPos(int breakPos) {
_lineBreakPos = breakPos;
}
public void setObfuscate(boolean obfuscate) {
_obfuscate = obfuscate;
}
public void setDisableMicroOptimizations(boolean disableMicroOptimizations) {
_disableMicroOptimizations = disableMicroOptimizations;
}
public void setPreserveUnecessarySemicolons(boolean preserveUnecessarySemicolons) {
_preserveUnecessarySemicolons = preserveUnecessarySemicolons;
}
public void setOutputPath(String outputPath) {
_outputPath = outputPath;
}
public void setConfigurationFromFile(String configurationPath) throws CompressorException, IOException {
|
_config = new YamlConfiguration();
|
switchfly/switchfly-java
|
inputvalidation/src/test/java/com/switchfly/inputvalidation/AddressLineValidationStrategiesTest.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
|
import com.switchfly.inputvalidation.exception.ValidatorException;
import org.junit.Test;
import static org.junit.Assert.*;
|
/**
* We have disabled HTML output encoding to so that special characters, such as ê and ú, are not also encoded.
* Unfortunately, without output encoding, many XSS attacks become *MUCH* more difficult to prevent.
* If the following tests fail, then we may be vulnerable to XSS attacks.
*/
assertValidationException("<", validationStrategy);
assertValidationException(">", validationStrategy);
assertValidationException("=", validationStrategy);
assertValidationException("{", validationStrategy);
assertValidationException("}", validationStrategy);
assertValidationException("\"", validationStrategy);
assertValidationException("(", validationStrategy);
assertValidationException(")", validationStrategy);
assertValidationException(";", validationStrategy);
/**
* HTML output encoding alone will not prevent HTML tag attribute attacks. DO NOT allow these characters: ( ) = "
*/
assertValidationException("1\" +onmouseover=alert(\"123123\") +", validationStrategy);
assertValidationException("1\"+onmouseover=alert(\"123123\")+", validationStrategy);
assertValidationException("1'+onmouseover=alert('123123')+", validationStrategy);
assertValidationException("1'onmouseover=alert('123123')", validationStrategy);
assertValidationException("1'onmouseover=alert(123123)", validationStrategy);
}
public static void assertValidationException(String html, ValidationStrategy<String> validationStrategy) {
try {
validationStrategy.validate(html);
fail("content should not be valid.");
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
// Path: inputvalidation/src/test/java/com/switchfly/inputvalidation/AddressLineValidationStrategiesTest.java
import com.switchfly.inputvalidation.exception.ValidatorException;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* We have disabled HTML output encoding to so that special characters, such as ê and ú, are not also encoded.
* Unfortunately, without output encoding, many XSS attacks become *MUCH* more difficult to prevent.
* If the following tests fail, then we may be vulnerable to XSS attacks.
*/
assertValidationException("<", validationStrategy);
assertValidationException(">", validationStrategy);
assertValidationException("=", validationStrategy);
assertValidationException("{", validationStrategy);
assertValidationException("}", validationStrategy);
assertValidationException("\"", validationStrategy);
assertValidationException("(", validationStrategy);
assertValidationException(")", validationStrategy);
assertValidationException(";", validationStrategy);
/**
* HTML output encoding alone will not prevent HTML tag attribute attacks. DO NOT allow these characters: ( ) = "
*/
assertValidationException("1\" +onmouseover=alert(\"123123\") +", validationStrategy);
assertValidationException("1\"+onmouseover=alert(\"123123\")+", validationStrategy);
assertValidationException("1'+onmouseover=alert('123123')+", validationStrategy);
assertValidationException("1'onmouseover=alert('123123')", validationStrategy);
assertValidationException("1'onmouseover=alert(123123)", validationStrategy);
}
public static void assertValidationException(String html, ValidationStrategy<String> validationStrategy) {
try {
validationStrategy.validate(html);
fail("content should not be valid.");
|
} catch (ValidatorException e) {
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/UrlCleanValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/StringCanonicalizer.java
// public class StringCanonicalizer implements Canonicalizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// try {
// return Normalizer.normalize(content, Normalizer.Form.NFC);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/UrlStripHtmlSanitizer.java
// public class UrlStripHtmlSanitizer implements Sanitizer<String> {
//
// private static final String ENCODING = "UTF-8";
// private static final String PARAMETER_SEPARATOR = "&";
// private static final String NAME_VALUE_SEPARATOR = "=";
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
//
// URI uri;
// try {
// uri = new URI(content);
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
//
// List<NameValuePair> cleanedPairs = parse(uri);
//
// String queryString = cleanedPairs.isEmpty() ? null : URLEncodedUtils.format(cleanedPairs, ENCODING);
//
// try {
// return URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), uri.getPath(), queryString, uri.getFragment()).toString();
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static List<NameValuePair> parse(URI uri) {
// final String query = uri.getRawQuery();
// return parse(query);
// }
//
// public static List<NameValuePair> parse(String queryString) {
// List<NameValuePair> result = Collections.emptyList();
// if (queryString != null && queryString.length() > 0) {
// result = new ArrayList<NameValuePair>();
// parse(result, new Scanner(queryString));
// }
// return result;
// }
//
// private static void parse(List<NameValuePair> parameters, Scanner scanner) {
// scanner.useDelimiter(PARAMETER_SEPARATOR);
// while (scanner.hasNext()) {
// String[] nameValue = scanner.next().split(NAME_VALUE_SEPARATOR, 2);
// if (nameValue.length == 0 || nameValue.length > 2) {
// throw new IllegalArgumentException("bad parameter");
// }
// String name = ValidationStrategy.PROPERTY_NAME.cleanStrategy().validate(nameValue[0]);
// String value = null;
// if (nameValue.length == 2) {
// value = ValidationStrategy.DEFAULT_WEB_CONTENT_VALIDATION.validate(nameValue[1]);
// }
// parameters.add(new BasicNameValuePair(name, value));
// }
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.StringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.UrlStripHtmlSanitizer;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class UrlCleanValidationStrategy extends ValidationStrategy<String> {
public UrlCleanValidationStrategy() {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/StringCanonicalizer.java
// public class StringCanonicalizer implements Canonicalizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// try {
// return Normalizer.normalize(content, Normalizer.Form.NFC);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/UrlStripHtmlSanitizer.java
// public class UrlStripHtmlSanitizer implements Sanitizer<String> {
//
// private static final String ENCODING = "UTF-8";
// private static final String PARAMETER_SEPARATOR = "&";
// private static final String NAME_VALUE_SEPARATOR = "=";
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
//
// URI uri;
// try {
// uri = new URI(content);
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
//
// List<NameValuePair> cleanedPairs = parse(uri);
//
// String queryString = cleanedPairs.isEmpty() ? null : URLEncodedUtils.format(cleanedPairs, ENCODING);
//
// try {
// return URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), uri.getPath(), queryString, uri.getFragment()).toString();
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static List<NameValuePair> parse(URI uri) {
// final String query = uri.getRawQuery();
// return parse(query);
// }
//
// public static List<NameValuePair> parse(String queryString) {
// List<NameValuePair> result = Collections.emptyList();
// if (queryString != null && queryString.length() > 0) {
// result = new ArrayList<NameValuePair>();
// parse(result, new Scanner(queryString));
// }
// return result;
// }
//
// private static void parse(List<NameValuePair> parameters, Scanner scanner) {
// scanner.useDelimiter(PARAMETER_SEPARATOR);
// while (scanner.hasNext()) {
// String[] nameValue = scanner.next().split(NAME_VALUE_SEPARATOR, 2);
// if (nameValue.length == 0 || nameValue.length > 2) {
// throw new IllegalArgumentException("bad parameter");
// }
// String name = ValidationStrategy.PROPERTY_NAME.cleanStrategy().validate(nameValue[0]);
// String value = null;
// if (nameValue.length == 2) {
// value = ValidationStrategy.DEFAULT_WEB_CONTENT_VALIDATION.validate(nameValue[1]);
// }
// parameters.add(new BasicNameValuePair(name, value));
// }
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/UrlCleanValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.StringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.UrlStripHtmlSanitizer;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class UrlCleanValidationStrategy extends ValidationStrategy<String> {
public UrlCleanValidationStrategy() {
|
super(new StringCanonicalizer(), null, new UrlStripHtmlSanitizer());
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/UrlCleanValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/StringCanonicalizer.java
// public class StringCanonicalizer implements Canonicalizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// try {
// return Normalizer.normalize(content, Normalizer.Form.NFC);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/UrlStripHtmlSanitizer.java
// public class UrlStripHtmlSanitizer implements Sanitizer<String> {
//
// private static final String ENCODING = "UTF-8";
// private static final String PARAMETER_SEPARATOR = "&";
// private static final String NAME_VALUE_SEPARATOR = "=";
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
//
// URI uri;
// try {
// uri = new URI(content);
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
//
// List<NameValuePair> cleanedPairs = parse(uri);
//
// String queryString = cleanedPairs.isEmpty() ? null : URLEncodedUtils.format(cleanedPairs, ENCODING);
//
// try {
// return URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), uri.getPath(), queryString, uri.getFragment()).toString();
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static List<NameValuePair> parse(URI uri) {
// final String query = uri.getRawQuery();
// return parse(query);
// }
//
// public static List<NameValuePair> parse(String queryString) {
// List<NameValuePair> result = Collections.emptyList();
// if (queryString != null && queryString.length() > 0) {
// result = new ArrayList<NameValuePair>();
// parse(result, new Scanner(queryString));
// }
// return result;
// }
//
// private static void parse(List<NameValuePair> parameters, Scanner scanner) {
// scanner.useDelimiter(PARAMETER_SEPARATOR);
// while (scanner.hasNext()) {
// String[] nameValue = scanner.next().split(NAME_VALUE_SEPARATOR, 2);
// if (nameValue.length == 0 || nameValue.length > 2) {
// throw new IllegalArgumentException("bad parameter");
// }
// String name = ValidationStrategy.PROPERTY_NAME.cleanStrategy().validate(nameValue[0]);
// String value = null;
// if (nameValue.length == 2) {
// value = ValidationStrategy.DEFAULT_WEB_CONTENT_VALIDATION.validate(nameValue[1]);
// }
// parameters.add(new BasicNameValuePair(name, value));
// }
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.StringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.UrlStripHtmlSanitizer;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class UrlCleanValidationStrategy extends ValidationStrategy<String> {
public UrlCleanValidationStrategy() {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/StringCanonicalizer.java
// public class StringCanonicalizer implements Canonicalizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// try {
// return Normalizer.normalize(content, Normalizer.Form.NFC);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/UrlStripHtmlSanitizer.java
// public class UrlStripHtmlSanitizer implements Sanitizer<String> {
//
// private static final String ENCODING = "UTF-8";
// private static final String PARAMETER_SEPARATOR = "&";
// private static final String NAME_VALUE_SEPARATOR = "=";
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
//
// URI uri;
// try {
// uri = new URI(content);
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
//
// List<NameValuePair> cleanedPairs = parse(uri);
//
// String queryString = cleanedPairs.isEmpty() ? null : URLEncodedUtils.format(cleanedPairs, ENCODING);
//
// try {
// return URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), uri.getPath(), queryString, uri.getFragment()).toString();
// } catch (URISyntaxException e) {
// throw new RuntimeException(e);
// }
// }
//
// public static List<NameValuePair> parse(URI uri) {
// final String query = uri.getRawQuery();
// return parse(query);
// }
//
// public static List<NameValuePair> parse(String queryString) {
// List<NameValuePair> result = Collections.emptyList();
// if (queryString != null && queryString.length() > 0) {
// result = new ArrayList<NameValuePair>();
// parse(result, new Scanner(queryString));
// }
// return result;
// }
//
// private static void parse(List<NameValuePair> parameters, Scanner scanner) {
// scanner.useDelimiter(PARAMETER_SEPARATOR);
// while (scanner.hasNext()) {
// String[] nameValue = scanner.next().split(NAME_VALUE_SEPARATOR, 2);
// if (nameValue.length == 0 || nameValue.length > 2) {
// throw new IllegalArgumentException("bad parameter");
// }
// String name = ValidationStrategy.PROPERTY_NAME.cleanStrategy().validate(nameValue[0]);
// String value = null;
// if (nameValue.length == 2) {
// value = ValidationStrategy.DEFAULT_WEB_CONTENT_VALIDATION.validate(nameValue[1]);
// }
// parameters.add(new BasicNameValuePair(name, value));
// }
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/UrlCleanValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.StringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.UrlStripHtmlSanitizer;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class UrlCleanValidationStrategy extends ValidationStrategy<String> {
public UrlCleanValidationStrategy() {
|
super(new StringCanonicalizer(), null, new UrlStripHtmlSanitizer());
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/WebContentValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlSanitizer.java
// public class StripHtmlSanitizer implements Sanitizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Document document = Jsoup.parse(content);
// document.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
// for (Element element : document.select("script,link,iframe,style")) {
// element.remove();
// }
// return document.text();
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlSanitizer;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class WebContentValidationStrategy extends ValidationStrategy<String> {
public WebContentValidationStrategy() {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlSanitizer.java
// public class StripHtmlSanitizer implements Sanitizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Document document = Jsoup.parse(content);
// document.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
// for (Element element : document.select("script,link,iframe,style")) {
// element.remove();
// }
// return document.text();
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/WebContentValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlSanitizer;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class WebContentValidationStrategy extends ValidationStrategy<String> {
public WebContentValidationStrategy() {
|
super(new HtmlAndQueryStringCanonicalizer(), null, new StripHtmlSanitizer());
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/WebContentValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlSanitizer.java
// public class StripHtmlSanitizer implements Sanitizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Document document = Jsoup.parse(content);
// document.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
// for (Element element : document.select("script,link,iframe,style")) {
// element.remove();
// }
// return document.text();
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlSanitizer;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class WebContentValidationStrategy extends ValidationStrategy<String> {
public WebContentValidationStrategy() {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/StripHtmlSanitizer.java
// public class StripHtmlSanitizer implements Sanitizer<String> {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Document document = Jsoup.parse(content);
// document.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
// for (Element element : document.select("script,link,iframe,style")) {
// element.remove();
// }
// return document.text();
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/WebContentValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.StripHtmlSanitizer;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class WebContentValidationStrategy extends ValidationStrategy<String> {
public WebContentValidationStrategy() {
|
super(new HtmlAndQueryStringCanonicalizer(), null, new StripHtmlSanitizer());
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/Parameter.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
|
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import com.switchfly.inputvalidation.exception.ValidatorException;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class Parameter<E> {
private final String _name;
private final E _value;
private final ValidationStrategy<String> _parameterNameValidationStrategy = new ParameterNameValidationStrategy();
private ValidationStrategy<E> _validationStrategy = new ValidationStrategy<E>(null, null, null);
public Parameter(String name, E value) {
_name = name;
_value = value;
}
protected E getValue() {
return _value;
}
public String getName() {
return _parameterNameValidationStrategy.validate(_name);
}
public Parameter<E> validateWith(ValidationStrategy<E> validationStrategy) {
_validationStrategy = validationStrategy;
return this;
}
public boolean isEmpty() {
return _value == null;
}
public E validate() {
if (isEmpty()) {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/Parameter.java
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import com.switchfly.inputvalidation.exception.ValidatorException;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class Parameter<E> {
private final String _name;
private final E _value;
private final ValidationStrategy<String> _parameterNameValidationStrategy = new ParameterNameValidationStrategy();
private ValidationStrategy<E> _validationStrategy = new ValidationStrategy<E>(null, null, null);
public Parameter(String name, E value) {
_name = name;
_value = value;
}
protected E getValue() {
return _value;
}
public String getName() {
return _parameterNameValidationStrategy.validate(_name);
}
public Parameter<E> validateWith(ValidationStrategy<E> validationStrategy) {
_validationStrategy = validationStrategy;
return this;
}
public boolean isEmpty() {
return _value == null;
}
public E validate() {
if (isEmpty()) {
|
throw new MissingRequestParameterException(getName());
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/Parameter.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
|
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import com.switchfly.inputvalidation.exception.ValidatorException;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class Parameter<E> {
private final String _name;
private final E _value;
private final ValidationStrategy<String> _parameterNameValidationStrategy = new ParameterNameValidationStrategy();
private ValidationStrategy<E> _validationStrategy = new ValidationStrategy<E>(null, null, null);
public Parameter(String name, E value) {
_name = name;
_value = value;
}
protected E getValue() {
return _value;
}
public String getName() {
return _parameterNameValidationStrategy.validate(_name);
}
public Parameter<E> validateWith(ValidationStrategy<E> validationStrategy) {
_validationStrategy = validationStrategy;
return this;
}
public boolean isEmpty() {
return _value == null;
}
public E validate() {
if (isEmpty()) {
throw new MissingRequestParameterException(getName());
}
try {
return _validationStrategy.validate(_value);
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/Parameter.java
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import com.switchfly.inputvalidation.exception.ValidatorException;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class Parameter<E> {
private final String _name;
private final E _value;
private final ValidationStrategy<String> _parameterNameValidationStrategy = new ParameterNameValidationStrategy();
private ValidationStrategy<E> _validationStrategy = new ValidationStrategy<E>(null, null, null);
public Parameter(String name, E value) {
_name = name;
_value = value;
}
protected E getValue() {
return _value;
}
public String getName() {
return _parameterNameValidationStrategy.validate(_name);
}
public Parameter<E> validateWith(ValidationStrategy<E> validationStrategy) {
_validationStrategy = validationStrategy;
return this;
}
public boolean isEmpty() {
return _value == null;
}
public E validate() {
if (isEmpty()) {
throw new MissingRequestParameterException(getName());
}
try {
return _validationStrategy.validate(_value);
|
} catch (ValidatorException e) {
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/Parameter.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
|
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import com.switchfly.inputvalidation.exception.ValidatorException;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class Parameter<E> {
private final String _name;
private final E _value;
private final ValidationStrategy<String> _parameterNameValidationStrategy = new ParameterNameValidationStrategy();
private ValidationStrategy<E> _validationStrategy = new ValidationStrategy<E>(null, null, null);
public Parameter(String name, E value) {
_name = name;
_value = value;
}
protected E getValue() {
return _value;
}
public String getName() {
return _parameterNameValidationStrategy.validate(_name);
}
public Parameter<E> validateWith(ValidationStrategy<E> validationStrategy) {
_validationStrategy = validationStrategy;
return this;
}
public boolean isEmpty() {
return _value == null;
}
public E validate() {
if (isEmpty()) {
throw new MissingRequestParameterException(getName());
}
try {
return _validationStrategy.validate(_value);
} catch (ValidatorException e) {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/Parameter.java
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import com.switchfly.inputvalidation.exception.ValidatorException;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class Parameter<E> {
private final String _name;
private final E _value;
private final ValidationStrategy<String> _parameterNameValidationStrategy = new ParameterNameValidationStrategy();
private ValidationStrategy<E> _validationStrategy = new ValidationStrategy<E>(null, null, null);
public Parameter(String name, E value) {
_name = name;
_value = value;
}
protected E getValue() {
return _value;
}
public String getName() {
return _parameterNameValidationStrategy.validate(_name);
}
public Parameter<E> validateWith(ValidationStrategy<E> validationStrategy) {
_validationStrategy = validationStrategy;
return this;
}
public boolean isEmpty() {
return _value == null;
}
public E validate() {
if (isEmpty()) {
throw new MissingRequestParameterException(getName());
}
try {
return _validationStrategy.validate(_value);
} catch (ValidatorException e) {
|
throw new InvalidRequestParameterException(getName(), e.getSanitizedContent());
|
switchfly/switchfly-java
|
inputvalidation/src/test/java/com/switchfly/inputvalidation/RequestParameterTest.java
|
// Path: compress/src/main/java/com/switchfly/compress/AssetPackageMode.java
// public enum AssetPackageMode {
// DEVELOPMENT,
// DEBUG,
// PRODUCTION
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/Validator.java
// public abstract class Validator<O> {
//
// private String _errorMessage;
//
// public abstract boolean execute(O content);
//
// public String getErrorMessage() {
// return _errorMessage;
// }
//
// public void setErrorMessage(String errorMessage) {
// _errorMessage = errorMessage;
// }
// }
|
import com.switchfly.compress.AssetPackageMode;
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import com.switchfly.inputvalidation.validator.Validator;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
|
return false;
}
}, null);
@Test
public void testGetName() throws Exception {
assertEquals("Abc-12_4", new RequestParameter("Abc-12_4", null).getName());
assertEquals("Abc-12_4_script", new RequestParameter("?Ab = c-1&2_4_!\"'<script>", null).getName());
assertEquals(null, new RequestParameter(null, null).getName());
assertEquals(" ", new RequestParameter(" ", null).getName());
assertEquals("", new RequestParameter("", null).getName());
}
@Test
public void testToStringWithValidValues() throws Exception {
assertEquals("foo", new RequestParameter(null, "foo").toString());
}
@Test
public void testToStringWithDefaultValues() throws Exception {
assertEquals("foo", new RequestParameter(null, "foo").toString("bar"));
assertEquals("bar", new RequestParameter(null, "").toString("bar"));
assertEquals("bar", new RequestParameter(null, null).toString("bar"));
assertEquals("bar", new RequestParameter(null, "foo").validateWith(ALWAYS_INVALID_VALIDATION).toString("bar"));
}
@Test
public void testToStringInvalidValues() throws Exception {
try {
new RequestParameter("foo", "").toString();
|
// Path: compress/src/main/java/com/switchfly/compress/AssetPackageMode.java
// public enum AssetPackageMode {
// DEVELOPMENT,
// DEBUG,
// PRODUCTION
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/Validator.java
// public abstract class Validator<O> {
//
// private String _errorMessage;
//
// public abstract boolean execute(O content);
//
// public String getErrorMessage() {
// return _errorMessage;
// }
//
// public void setErrorMessage(String errorMessage) {
// _errorMessage = errorMessage;
// }
// }
// Path: inputvalidation/src/test/java/com/switchfly/inputvalidation/RequestParameterTest.java
import com.switchfly.compress.AssetPackageMode;
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import com.switchfly.inputvalidation.validator.Validator;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
return false;
}
}, null);
@Test
public void testGetName() throws Exception {
assertEquals("Abc-12_4", new RequestParameter("Abc-12_4", null).getName());
assertEquals("Abc-12_4_script", new RequestParameter("?Ab = c-1&2_4_!\"'<script>", null).getName());
assertEquals(null, new RequestParameter(null, null).getName());
assertEquals(" ", new RequestParameter(" ", null).getName());
assertEquals("", new RequestParameter("", null).getName());
}
@Test
public void testToStringWithValidValues() throws Exception {
assertEquals("foo", new RequestParameter(null, "foo").toString());
}
@Test
public void testToStringWithDefaultValues() throws Exception {
assertEquals("foo", new RequestParameter(null, "foo").toString("bar"));
assertEquals("bar", new RequestParameter(null, "").toString("bar"));
assertEquals("bar", new RequestParameter(null, null).toString("bar"));
assertEquals("bar", new RequestParameter(null, "foo").validateWith(ALWAYS_INVALID_VALIDATION).toString("bar"));
}
@Test
public void testToStringInvalidValues() throws Exception {
try {
new RequestParameter("foo", "").toString();
|
} catch (MissingRequestParameterException e) {
|
switchfly/switchfly-java
|
inputvalidation/src/test/java/com/switchfly/inputvalidation/RequestParameterTest.java
|
// Path: compress/src/main/java/com/switchfly/compress/AssetPackageMode.java
// public enum AssetPackageMode {
// DEVELOPMENT,
// DEBUG,
// PRODUCTION
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/Validator.java
// public abstract class Validator<O> {
//
// private String _errorMessage;
//
// public abstract boolean execute(O content);
//
// public String getErrorMessage() {
// return _errorMessage;
// }
//
// public void setErrorMessage(String errorMessage) {
// _errorMessage = errorMessage;
// }
// }
|
import com.switchfly.compress.AssetPackageMode;
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import com.switchfly.inputvalidation.validator.Validator;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
|
@Test
public void testToStringWithValidValues() throws Exception {
assertEquals("foo", new RequestParameter(null, "foo").toString());
}
@Test
public void testToStringWithDefaultValues() throws Exception {
assertEquals("foo", new RequestParameter(null, "foo").toString("bar"));
assertEquals("bar", new RequestParameter(null, "").toString("bar"));
assertEquals("bar", new RequestParameter(null, null).toString("bar"));
assertEquals("bar", new RequestParameter(null, "foo").validateWith(ALWAYS_INVALID_VALIDATION).toString("bar"));
}
@Test
public void testToStringInvalidValues() throws Exception {
try {
new RequestParameter("foo", "").toString();
} catch (MissingRequestParameterException e) {
assertEquals("foo", e.getParameterName());
}
try {
new RequestParameter("foo", null).toString();
} catch (MissingRequestParameterException e) {
assertEquals("foo", e.getParameterName());
}
try {
new RequestParameter("foo", "bar").validateWith(ALWAYS_INVALID_VALIDATION).toString();
|
// Path: compress/src/main/java/com/switchfly/compress/AssetPackageMode.java
// public enum AssetPackageMode {
// DEVELOPMENT,
// DEBUG,
// PRODUCTION
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/Validator.java
// public abstract class Validator<O> {
//
// private String _errorMessage;
//
// public abstract boolean execute(O content);
//
// public String getErrorMessage() {
// return _errorMessage;
// }
//
// public void setErrorMessage(String errorMessage) {
// _errorMessage = errorMessage;
// }
// }
// Path: inputvalidation/src/test/java/com/switchfly/inputvalidation/RequestParameterTest.java
import com.switchfly.compress.AssetPackageMode;
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import com.switchfly.inputvalidation.validator.Validator;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
@Test
public void testToStringWithValidValues() throws Exception {
assertEquals("foo", new RequestParameter(null, "foo").toString());
}
@Test
public void testToStringWithDefaultValues() throws Exception {
assertEquals("foo", new RequestParameter(null, "foo").toString("bar"));
assertEquals("bar", new RequestParameter(null, "").toString("bar"));
assertEquals("bar", new RequestParameter(null, null).toString("bar"));
assertEquals("bar", new RequestParameter(null, "foo").validateWith(ALWAYS_INVALID_VALIDATION).toString("bar"));
}
@Test
public void testToStringInvalidValues() throws Exception {
try {
new RequestParameter("foo", "").toString();
} catch (MissingRequestParameterException e) {
assertEquals("foo", e.getParameterName());
}
try {
new RequestParameter("foo", null).toString();
} catch (MissingRequestParameterException e) {
assertEquals("foo", e.getParameterName());
}
try {
new RequestParameter("foo", "bar").validateWith(ALWAYS_INVALID_VALIDATION).toString();
|
} catch (InvalidRequestParameterException e) {
|
switchfly/switchfly-java
|
inputvalidation/src/test/java/com/switchfly/inputvalidation/RequestParameterTest.java
|
// Path: compress/src/main/java/com/switchfly/compress/AssetPackageMode.java
// public enum AssetPackageMode {
// DEVELOPMENT,
// DEBUG,
// PRODUCTION
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/Validator.java
// public abstract class Validator<O> {
//
// private String _errorMessage;
//
// public abstract boolean execute(O content);
//
// public String getErrorMessage() {
// return _errorMessage;
// }
//
// public void setErrorMessage(String errorMessage) {
// _errorMessage = errorMessage;
// }
// }
|
import com.switchfly.compress.AssetPackageMode;
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import com.switchfly.inputvalidation.validator.Validator;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
|
assertEquals(true, new RequestParameter(null, "true").toBoolean(false));
assertEquals(true, new RequestParameter(null, "").toBoolean(true));
assertEquals(true, new RequestParameter(null, null).toBoolean(true));
assertEquals(false, new RequestParameter(null, "true").validateWith(ALWAYS_INVALID_VALIDATION).toBoolean(false));
}
@Test
public void testToBooleanWithInvalidValues() throws Exception {
try {
new RequestParameter("foo", "").toBoolean();
} catch (MissingRequestParameterException e) {
assertEquals("foo", e.getParameterName());
}
try {
new RequestParameter("foo", null).toBoolean();
} catch (MissingRequestParameterException e) {
assertEquals("foo", e.getParameterName());
}
try {
new RequestParameter("foo", "true").validateWith(ALWAYS_INVALID_VALIDATION).toBoolean();
} catch (InvalidRequestParameterException e) {
assertEquals("foo", e.getParameterName());
assertEquals("true", e.getParameterValue());
}
}
@Test
public void testToEnumWithValidValues() throws Exception {
|
// Path: compress/src/main/java/com/switchfly/compress/AssetPackageMode.java
// public enum AssetPackageMode {
// DEVELOPMENT,
// DEBUG,
// PRODUCTION
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/Validator.java
// public abstract class Validator<O> {
//
// private String _errorMessage;
//
// public abstract boolean execute(O content);
//
// public String getErrorMessage() {
// return _errorMessage;
// }
//
// public void setErrorMessage(String errorMessage) {
// _errorMessage = errorMessage;
// }
// }
// Path: inputvalidation/src/test/java/com/switchfly/inputvalidation/RequestParameterTest.java
import com.switchfly.compress.AssetPackageMode;
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import com.switchfly.inputvalidation.validator.Validator;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
assertEquals(true, new RequestParameter(null, "true").toBoolean(false));
assertEquals(true, new RequestParameter(null, "").toBoolean(true));
assertEquals(true, new RequestParameter(null, null).toBoolean(true));
assertEquals(false, new RequestParameter(null, "true").validateWith(ALWAYS_INVALID_VALIDATION).toBoolean(false));
}
@Test
public void testToBooleanWithInvalidValues() throws Exception {
try {
new RequestParameter("foo", "").toBoolean();
} catch (MissingRequestParameterException e) {
assertEquals("foo", e.getParameterName());
}
try {
new RequestParameter("foo", null).toBoolean();
} catch (MissingRequestParameterException e) {
assertEquals("foo", e.getParameterName());
}
try {
new RequestParameter("foo", "true").validateWith(ALWAYS_INVALID_VALIDATION).toBoolean();
} catch (InvalidRequestParameterException e) {
assertEquals("foo", e.getParameterName());
assertEquals("true", e.getParameterValue());
}
}
@Test
public void testToEnumWithValidValues() throws Exception {
|
assertEquals(AssetPackageMode.PRODUCTION, new RequestParameter(null, "PRODUCTION").toEnum(AssetPackageMode.class));
|
switchfly/switchfly-java
|
inputvalidation/src/test/java/com/switchfly/inputvalidation/CobrandNameValidationStrategyTest.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
|
import com.switchfly.inputvalidation.exception.ValidatorException;
import org.apache.commons.collections.Closure;
import org.junit.Test;
import static org.junit.Assert.*;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class CobrandNameValidationStrategyTest {
@Test
public void testCleanStrategy() throws Exception {
assertEquals("", ValidationStrategy.COBRAND_NAME.cleanStrategy().validate(""));
assertEquals(" ", ValidationStrategy.COBRAND_NAME.cleanStrategy().validate(" "));
assertEquals(null, ValidationStrategy.COBRAND_NAME.cleanStrategy().validate(null));
assertEquals("foo-Bar_123üaàé", ValidationStrategy.COBRAND_NAME.cleanStrategy().validate("foo-Bar_123üaàé"));
assertEquals("etcpasswd", ValidationStrategy.COBRAND_NAME.cleanStrategy().validate("../../../../../etc/passwd%00"));
assertEquals("etcpasswd00foo", ValidationStrategy.COBRAND_NAME.cleanStrategy().validate("../../../../../etc/passwd%00%foo"));
assertEquals("default00", ValidationStrategy.COBRAND_NAME.cleanStrategy().validate("default%00%<script>alert('hacked')</script>"));
}
@Test
public void testValidateStrategy() throws Exception {
assertEquals("", ValidationStrategy.COBRAND_NAME.validateStrategy().validate(""));
assertEquals(" ", ValidationStrategy.COBRAND_NAME.validateStrategy().validate(" "));
assertEquals(null, ValidationStrategy.COBRAND_NAME.validateStrategy().validate(null));
assertEquals("foo-Bar_123", ValidationStrategy.COBRAND_NAME.validateStrategy().validate("foo-Bar_123"));
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
// Path: inputvalidation/src/test/java/com/switchfly/inputvalidation/CobrandNameValidationStrategyTest.java
import com.switchfly.inputvalidation.exception.ValidatorException;
import org.apache.commons.collections.Closure;
import org.junit.Test;
import static org.junit.Assert.*;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class CobrandNameValidationStrategyTest {
@Test
public void testCleanStrategy() throws Exception {
assertEquals("", ValidationStrategy.COBRAND_NAME.cleanStrategy().validate(""));
assertEquals(" ", ValidationStrategy.COBRAND_NAME.cleanStrategy().validate(" "));
assertEquals(null, ValidationStrategy.COBRAND_NAME.cleanStrategy().validate(null));
assertEquals("foo-Bar_123üaàé", ValidationStrategy.COBRAND_NAME.cleanStrategy().validate("foo-Bar_123üaàé"));
assertEquals("etcpasswd", ValidationStrategy.COBRAND_NAME.cleanStrategy().validate("../../../../../etc/passwd%00"));
assertEquals("etcpasswd00foo", ValidationStrategy.COBRAND_NAME.cleanStrategy().validate("../../../../../etc/passwd%00%foo"));
assertEquals("default00", ValidationStrategy.COBRAND_NAME.cleanStrategy().validate("default%00%<script>alert('hacked')</script>"));
}
@Test
public void testValidateStrategy() throws Exception {
assertEquals("", ValidationStrategy.COBRAND_NAME.validateStrategy().validate(""));
assertEquals(" ", ValidationStrategy.COBRAND_NAME.validateStrategy().validate(" "));
assertEquals(null, ValidationStrategy.COBRAND_NAME.validateStrategy().validate(null));
assertEquals("foo-Bar_123", ValidationStrategy.COBRAND_NAME.validateStrategy().validate("foo-Bar_123"));
|
assertThrowException(ValidatorException.class, new Closure() {
|
switchfly/switchfly-java
|
inputvalidation/src/test/java/com/switchfly/inputvalidation/UrlValidationStrategyTest.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
|
import com.switchfly.inputvalidation.exception.ValidatorException;
import org.junit.Test;
import static org.junit.Assert.*;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class UrlValidationStrategyTest {
@Test
public void testValidate() throws Exception {
UrlValidationStrategy validationStrategy = new UrlValidationStrategy();
assertEquals("http://www.foo.com/to/page.cfm?a=1&b=2#bar", validationStrategy.validate("http://www.foo.com/to/page.cfm?a=1&b=2#bar"));
assertEquals("https://www.foo.com/to/page.cfm?a=1&b=2#bar", validationStrategy.validate("https://www.foo.com/to/page.cfm?a=1&b=2#bar"));
assertEquals("/to/page.cfm?a=1&b=2#bar", validationStrategy.validate("/to/page.cfm?a=1&b=2#bar"));
assertValidationException("data%3atext%2fht%%206dl%3bbase64%2cPHdoc2N%20oZWNrPg%3d%3d", validationStrategy);
}
public static void assertValidationException(String content, ValidationStrategy<String> validationStrategy) {
try {
validationStrategy.validate(content);
fail("content should not be valid.");
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
// Path: inputvalidation/src/test/java/com/switchfly/inputvalidation/UrlValidationStrategyTest.java
import com.switchfly.inputvalidation.exception.ValidatorException;
import org.junit.Test;
import static org.junit.Assert.*;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class UrlValidationStrategyTest {
@Test
public void testValidate() throws Exception {
UrlValidationStrategy validationStrategy = new UrlValidationStrategy();
assertEquals("http://www.foo.com/to/page.cfm?a=1&b=2#bar", validationStrategy.validate("http://www.foo.com/to/page.cfm?a=1&b=2#bar"));
assertEquals("https://www.foo.com/to/page.cfm?a=1&b=2#bar", validationStrategy.validate("https://www.foo.com/to/page.cfm?a=1&b=2#bar"));
assertEquals("/to/page.cfm?a=1&b=2#bar", validationStrategy.validate("/to/page.cfm?a=1&b=2#bar"));
assertValidationException("data%3atext%2fht%%206dl%3bbase64%2cPHdoc2N%20oZWNrPg%3d%3d", validationStrategy);
}
public static void assertValidationException(String content, ValidationStrategy<String> validationStrategy) {
try {
validationStrategy.validate(content);
fail("content should not be valid.");
|
} catch (ValidatorException e) {
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/ParameterNameValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/ParameterNameSanitizer.java
// public class ParameterNameSanitizer implements Sanitizer<String> {
//
// private static final Pattern PATTERN = Pattern.compile("[^\\w_-]");
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// return PATTERN.matcher(content).replaceAll("");
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.ParameterNameSanitizer;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class ParameterNameValidationStrategy extends ValidationStrategy<String> {
public ParameterNameValidationStrategy() {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/ParameterNameSanitizer.java
// public class ParameterNameSanitizer implements Sanitizer<String> {
//
// private static final Pattern PATTERN = Pattern.compile("[^\\w_-]");
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// return PATTERN.matcher(content).replaceAll("");
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/ParameterNameValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.ParameterNameSanitizer;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class ParameterNameValidationStrategy extends ValidationStrategy<String> {
public ParameterNameValidationStrategy() {
|
super(new HtmlAndQueryStringCanonicalizer(), null, new ParameterNameSanitizer());
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/ParameterNameValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/ParameterNameSanitizer.java
// public class ParameterNameSanitizer implements Sanitizer<String> {
//
// private static final Pattern PATTERN = Pattern.compile("[^\\w_-]");
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// return PATTERN.matcher(content).replaceAll("");
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.ParameterNameSanitizer;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class ParameterNameValidationStrategy extends ValidationStrategy<String> {
public ParameterNameValidationStrategy() {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/ParameterNameSanitizer.java
// public class ParameterNameSanitizer implements Sanitizer<String> {
//
// private static final Pattern PATTERN = Pattern.compile("[^\\w_-]");
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// return PATTERN.matcher(content).replaceAll("");
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/ParameterNameValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.ParameterNameSanitizer;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class ParameterNameValidationStrategy extends ValidationStrategy<String> {
public ParameterNameValidationStrategy() {
|
super(new HtmlAndQueryStringCanonicalizer(), null, new ParameterNameSanitizer());
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/ValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/Canonicalizer.java
// public interface Canonicalizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/Sanitizer.java
// public interface Sanitizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/Validator.java
// public abstract class Validator<O> {
//
// private String _errorMessage;
//
// public abstract boolean execute(O content);
//
// public String getErrorMessage() {
// return _errorMessage;
// }
//
// public void setErrorMessage(String errorMessage) {
// _errorMessage = errorMessage;
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.Canonicalizer;
import com.switchfly.inputvalidation.exception.ValidatorException;
import com.switchfly.inputvalidation.sanitizer.Sanitizer;
import com.switchfly.inputvalidation.validator.Validator;
import org.apache.commons.lang.StringUtils;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class ValidationStrategy<O> {
public static final ValidationStrategy<String> DEFAULT_WEB_CONTENT_VALIDATION = new WebContentValidationStrategy();
public static final ValidationStrategy<String> CLEAN_CURRENCY_CODE = new CurrencyCodeValidationStrategy();
public static final ValidationStrategy<String> CLEAN_LOCALE_CODE = new LocaleCodeValidationStrategy();
public static final ValidationStrategy<String> CLEAN_URL = new UrlCleanValidationStrategy();
public static final ValidationStrategies COBRAND_NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\-_]+");
public static final ValidationStrategies ADDRESS_LINE = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\.\\-\\s#&',:\\/\\\\]+");
public static final ValidationStrategies NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}_\\.\\-\\s~,'`]+");
public static final ValidationStrategies PROPERTY_NAME = ValidationStrategyBuilder.withPattern("[\\w\\d\\-\\._]+");
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/Canonicalizer.java
// public interface Canonicalizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/Sanitizer.java
// public interface Sanitizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/Validator.java
// public abstract class Validator<O> {
//
// private String _errorMessage;
//
// public abstract boolean execute(O content);
//
// public String getErrorMessage() {
// return _errorMessage;
// }
//
// public void setErrorMessage(String errorMessage) {
// _errorMessage = errorMessage;
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/ValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.Canonicalizer;
import com.switchfly.inputvalidation.exception.ValidatorException;
import com.switchfly.inputvalidation.sanitizer.Sanitizer;
import com.switchfly.inputvalidation.validator.Validator;
import org.apache.commons.lang.StringUtils;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class ValidationStrategy<O> {
public static final ValidationStrategy<String> DEFAULT_WEB_CONTENT_VALIDATION = new WebContentValidationStrategy();
public static final ValidationStrategy<String> CLEAN_CURRENCY_CODE = new CurrencyCodeValidationStrategy();
public static final ValidationStrategy<String> CLEAN_LOCALE_CODE = new LocaleCodeValidationStrategy();
public static final ValidationStrategy<String> CLEAN_URL = new UrlCleanValidationStrategy();
public static final ValidationStrategies COBRAND_NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\-_]+");
public static final ValidationStrategies ADDRESS_LINE = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\.\\-\\s#&',:\\/\\\\]+");
public static final ValidationStrategies NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}_\\.\\-\\s~,'`]+");
public static final ValidationStrategies PROPERTY_NAME = ValidationStrategyBuilder.withPattern("[\\w\\d\\-\\._]+");
|
private final Canonicalizer<O> _canonicalizer;
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/ValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/Canonicalizer.java
// public interface Canonicalizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/Sanitizer.java
// public interface Sanitizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/Validator.java
// public abstract class Validator<O> {
//
// private String _errorMessage;
//
// public abstract boolean execute(O content);
//
// public String getErrorMessage() {
// return _errorMessage;
// }
//
// public void setErrorMessage(String errorMessage) {
// _errorMessage = errorMessage;
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.Canonicalizer;
import com.switchfly.inputvalidation.exception.ValidatorException;
import com.switchfly.inputvalidation.sanitizer.Sanitizer;
import com.switchfly.inputvalidation.validator.Validator;
import org.apache.commons.lang.StringUtils;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class ValidationStrategy<O> {
public static final ValidationStrategy<String> DEFAULT_WEB_CONTENT_VALIDATION = new WebContentValidationStrategy();
public static final ValidationStrategy<String> CLEAN_CURRENCY_CODE = new CurrencyCodeValidationStrategy();
public static final ValidationStrategy<String> CLEAN_LOCALE_CODE = new LocaleCodeValidationStrategy();
public static final ValidationStrategy<String> CLEAN_URL = new UrlCleanValidationStrategy();
public static final ValidationStrategies COBRAND_NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\-_]+");
public static final ValidationStrategies ADDRESS_LINE = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\.\\-\\s#&',:\\/\\\\]+");
public static final ValidationStrategies NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}_\\.\\-\\s~,'`]+");
public static final ValidationStrategies PROPERTY_NAME = ValidationStrategyBuilder.withPattern("[\\w\\d\\-\\._]+");
private final Canonicalizer<O> _canonicalizer;
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/Canonicalizer.java
// public interface Canonicalizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/Sanitizer.java
// public interface Sanitizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/Validator.java
// public abstract class Validator<O> {
//
// private String _errorMessage;
//
// public abstract boolean execute(O content);
//
// public String getErrorMessage() {
// return _errorMessage;
// }
//
// public void setErrorMessage(String errorMessage) {
// _errorMessage = errorMessage;
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/ValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.Canonicalizer;
import com.switchfly.inputvalidation.exception.ValidatorException;
import com.switchfly.inputvalidation.sanitizer.Sanitizer;
import com.switchfly.inputvalidation.validator.Validator;
import org.apache.commons.lang.StringUtils;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class ValidationStrategy<O> {
public static final ValidationStrategy<String> DEFAULT_WEB_CONTENT_VALIDATION = new WebContentValidationStrategy();
public static final ValidationStrategy<String> CLEAN_CURRENCY_CODE = new CurrencyCodeValidationStrategy();
public static final ValidationStrategy<String> CLEAN_LOCALE_CODE = new LocaleCodeValidationStrategy();
public static final ValidationStrategy<String> CLEAN_URL = new UrlCleanValidationStrategy();
public static final ValidationStrategies COBRAND_NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\-_]+");
public static final ValidationStrategies ADDRESS_LINE = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\.\\-\\s#&',:\\/\\\\]+");
public static final ValidationStrategies NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}_\\.\\-\\s~,'`]+");
public static final ValidationStrategies PROPERTY_NAME = ValidationStrategyBuilder.withPattern("[\\w\\d\\-\\._]+");
private final Canonicalizer<O> _canonicalizer;
|
private final Validator<O> _validator;
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/ValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/Canonicalizer.java
// public interface Canonicalizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/Sanitizer.java
// public interface Sanitizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/Validator.java
// public abstract class Validator<O> {
//
// private String _errorMessage;
//
// public abstract boolean execute(O content);
//
// public String getErrorMessage() {
// return _errorMessage;
// }
//
// public void setErrorMessage(String errorMessage) {
// _errorMessage = errorMessage;
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.Canonicalizer;
import com.switchfly.inputvalidation.exception.ValidatorException;
import com.switchfly.inputvalidation.sanitizer.Sanitizer;
import com.switchfly.inputvalidation.validator.Validator;
import org.apache.commons.lang.StringUtils;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class ValidationStrategy<O> {
public static final ValidationStrategy<String> DEFAULT_WEB_CONTENT_VALIDATION = new WebContentValidationStrategy();
public static final ValidationStrategy<String> CLEAN_CURRENCY_CODE = new CurrencyCodeValidationStrategy();
public static final ValidationStrategy<String> CLEAN_LOCALE_CODE = new LocaleCodeValidationStrategy();
public static final ValidationStrategy<String> CLEAN_URL = new UrlCleanValidationStrategy();
public static final ValidationStrategies COBRAND_NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\-_]+");
public static final ValidationStrategies ADDRESS_LINE = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\.\\-\\s#&',:\\/\\\\]+");
public static final ValidationStrategies NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}_\\.\\-\\s~,'`]+");
public static final ValidationStrategies PROPERTY_NAME = ValidationStrategyBuilder.withPattern("[\\w\\d\\-\\._]+");
private final Canonicalizer<O> _canonicalizer;
private final Validator<O> _validator;
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/Canonicalizer.java
// public interface Canonicalizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/Sanitizer.java
// public interface Sanitizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/Validator.java
// public abstract class Validator<O> {
//
// private String _errorMessage;
//
// public abstract boolean execute(O content);
//
// public String getErrorMessage() {
// return _errorMessage;
// }
//
// public void setErrorMessage(String errorMessage) {
// _errorMessage = errorMessage;
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/ValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.Canonicalizer;
import com.switchfly.inputvalidation.exception.ValidatorException;
import com.switchfly.inputvalidation.sanitizer.Sanitizer;
import com.switchfly.inputvalidation.validator.Validator;
import org.apache.commons.lang.StringUtils;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class ValidationStrategy<O> {
public static final ValidationStrategy<String> DEFAULT_WEB_CONTENT_VALIDATION = new WebContentValidationStrategy();
public static final ValidationStrategy<String> CLEAN_CURRENCY_CODE = new CurrencyCodeValidationStrategy();
public static final ValidationStrategy<String> CLEAN_LOCALE_CODE = new LocaleCodeValidationStrategy();
public static final ValidationStrategy<String> CLEAN_URL = new UrlCleanValidationStrategy();
public static final ValidationStrategies COBRAND_NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\-_]+");
public static final ValidationStrategies ADDRESS_LINE = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\.\\-\\s#&',:\\/\\\\]+");
public static final ValidationStrategies NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}_\\.\\-\\s~,'`]+");
public static final ValidationStrategies PROPERTY_NAME = ValidationStrategyBuilder.withPattern("[\\w\\d\\-\\._]+");
private final Canonicalizer<O> _canonicalizer;
private final Validator<O> _validator;
|
private final Sanitizer<O> _sanitizer;
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/ValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/Canonicalizer.java
// public interface Canonicalizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/Sanitizer.java
// public interface Sanitizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/Validator.java
// public abstract class Validator<O> {
//
// private String _errorMessage;
//
// public abstract boolean execute(O content);
//
// public String getErrorMessage() {
// return _errorMessage;
// }
//
// public void setErrorMessage(String errorMessage) {
// _errorMessage = errorMessage;
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.Canonicalizer;
import com.switchfly.inputvalidation.exception.ValidatorException;
import com.switchfly.inputvalidation.sanitizer.Sanitizer;
import com.switchfly.inputvalidation.validator.Validator;
import org.apache.commons.lang.StringUtils;
|
public static final ValidationStrategies NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}_\\.\\-\\s~,'`]+");
public static final ValidationStrategies PROPERTY_NAME = ValidationStrategyBuilder.withPattern("[\\w\\d\\-\\._]+");
private final Canonicalizer<O> _canonicalizer;
private final Validator<O> _validator;
private final Sanitizer<O> _sanitizer;
public ValidationStrategy(Canonicalizer<O> canonicalizer, Validator<O> validator, Sanitizer<O> sanitizer) {
_canonicalizer = canonicalizer;
_validator = validator;
_sanitizer = sanitizer;
}
public final Canonicalizer<O> getCanonicalizer() {
return _canonicalizer;
}
public final Validator<O> getValidator() {
return _validator;
}
public final Sanitizer<O> getSanitizer() {
return _sanitizer;
}
public final O validate(O content) {
O canonicalized = null;
try {
canonicalized = _canonicalizer != null ? _canonicalizer.execute(content) : content;
} catch (Exception e) {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/Canonicalizer.java
// public interface Canonicalizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/Sanitizer.java
// public interface Sanitizer<O> {
//
// O execute(O content);
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/Validator.java
// public abstract class Validator<O> {
//
// private String _errorMessage;
//
// public abstract boolean execute(O content);
//
// public String getErrorMessage() {
// return _errorMessage;
// }
//
// public void setErrorMessage(String errorMessage) {
// _errorMessage = errorMessage;
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/ValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.Canonicalizer;
import com.switchfly.inputvalidation.exception.ValidatorException;
import com.switchfly.inputvalidation.sanitizer.Sanitizer;
import com.switchfly.inputvalidation.validator.Validator;
import org.apache.commons.lang.StringUtils;
public static final ValidationStrategies NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}_\\.\\-\\s~,'`]+");
public static final ValidationStrategies PROPERTY_NAME = ValidationStrategyBuilder.withPattern("[\\w\\d\\-\\._]+");
private final Canonicalizer<O> _canonicalizer;
private final Validator<O> _validator;
private final Sanitizer<O> _sanitizer;
public ValidationStrategy(Canonicalizer<O> canonicalizer, Validator<O> validator, Sanitizer<O> sanitizer) {
_canonicalizer = canonicalizer;
_validator = validator;
_sanitizer = sanitizer;
}
public final Canonicalizer<O> getCanonicalizer() {
return _canonicalizer;
}
public final Validator<O> getValidator() {
return _validator;
}
public final Sanitizer<O> getSanitizer() {
return _sanitizer;
}
public final O validate(O content) {
O canonicalized = null;
try {
canonicalized = _canonicalizer != null ? _canonicalizer.execute(content) : content;
} catch (Exception e) {
|
throw new ValidatorException("", "Failed to canonicalize content.");
|
switchfly/switchfly-java
|
compress/src/test/java/com/switchfly/compress/compressor/GoogleClosureJsCompressorIntegrationTest.java
|
// Path: compress/src/test/java/com/switchfly/compress/TestingUtil.java
// public class TestingUtil {
//
// public static String readFile(Class clazz, String resource) throws IOException {
// return IOUtils.toString(clazz.getResourceAsStream(resource));
// }
//
// public static void assertEqualsIgnoreWhitespace(String expected, String actual) {
// if (normalizeWhiteSpace(expected).equals(normalizeWhiteSpace(actual))) {
// return;
// }
// assertEquals(expected, actual);
// }
//
// // Trim and replace any white space between characters, newlines, carriage returns, etc. with one space " \t ab c" => " ab c"
// // Good for maintaining space for XML documents, if you used equalsIgnoreWhiteSpace it would make "a href" => "ahref"
// public static String normalizeWhiteSpace(String s) {
// return s.replaceAll("\\s+", "").trim();
// }
// }
|
import java.util.logging.Level;
import java.util.logging.Logger;
import com.switchfly.compress.TestingUtil;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.compress.compressor;
public class GoogleClosureJsCompressorIntegrationTest {
@Test
public void testCompress() throws Exception {
GoogleClosureJsCompressor packager = new GoogleClosureJsCompressor();
// Disable logging for js compressor
Logger.getLogger("com.google.javascript.jscomp").setLevel(Level.OFF);
|
// Path: compress/src/test/java/com/switchfly/compress/TestingUtil.java
// public class TestingUtil {
//
// public static String readFile(Class clazz, String resource) throws IOException {
// return IOUtils.toString(clazz.getResourceAsStream(resource));
// }
//
// public static void assertEqualsIgnoreWhitespace(String expected, String actual) {
// if (normalizeWhiteSpace(expected).equals(normalizeWhiteSpace(actual))) {
// return;
// }
// assertEquals(expected, actual);
// }
//
// // Trim and replace any white space between characters, newlines, carriage returns, etc. with one space " \t ab c" => " ab c"
// // Good for maintaining space for XML documents, if you used equalsIgnoreWhiteSpace it would make "a href" => "ahref"
// public static String normalizeWhiteSpace(String s) {
// return s.replaceAll("\\s+", "").trim();
// }
// }
// Path: compress/src/test/java/com/switchfly/compress/compressor/GoogleClosureJsCompressorIntegrationTest.java
import java.util.logging.Level;
import java.util.logging.Logger;
import com.switchfly.compress.TestingUtil;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.compress.compressor;
public class GoogleClosureJsCompressorIntegrationTest {
@Test
public void testCompress() throws Exception {
GoogleClosureJsCompressor packager = new GoogleClosureJsCompressor();
// Disable logging for js compressor
Logger.getLogger("com.google.javascript.jscomp").setLevel(Level.OFF);
|
String source = TestingUtil.readFile(getClass(), "uncompressed.js.txt");
|
switchfly/switchfly-java
|
compress/src/test/java/com/switchfly/compress/compressor/YuiJsCompressorIntegrationTest.java
|
// Path: compress/src/test/java/com/switchfly/compress/TestingUtil.java
// public class TestingUtil {
//
// public static String readFile(Class clazz, String resource) throws IOException {
// return IOUtils.toString(clazz.getResourceAsStream(resource));
// }
//
// public static void assertEqualsIgnoreWhitespace(String expected, String actual) {
// if (normalizeWhiteSpace(expected).equals(normalizeWhiteSpace(actual))) {
// return;
// }
// assertEquals(expected, actual);
// }
//
// // Trim and replace any white space between characters, newlines, carriage returns, etc. with one space " \t ab c" => " ab c"
// // Good for maintaining space for XML documents, if you used equalsIgnoreWhiteSpace it would make "a href" => "ahref"
// public static String normalizeWhiteSpace(String s) {
// return s.replaceAll("\\s+", "").trim();
// }
// }
|
import com.switchfly.compress.TestingUtil;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.compress.compressor;
public class YuiJsCompressorIntegrationTest {
@Test
public void testCompress() throws Exception {
YuiJsCompressor packager = new YuiJsCompressor();
|
// Path: compress/src/test/java/com/switchfly/compress/TestingUtil.java
// public class TestingUtil {
//
// public static String readFile(Class clazz, String resource) throws IOException {
// return IOUtils.toString(clazz.getResourceAsStream(resource));
// }
//
// public static void assertEqualsIgnoreWhitespace(String expected, String actual) {
// if (normalizeWhiteSpace(expected).equals(normalizeWhiteSpace(actual))) {
// return;
// }
// assertEquals(expected, actual);
// }
//
// // Trim and replace any white space between characters, newlines, carriage returns, etc. with one space " \t ab c" => " ab c"
// // Good for maintaining space for XML documents, if you used equalsIgnoreWhiteSpace it would make "a href" => "ahref"
// public static String normalizeWhiteSpace(String s) {
// return s.replaceAll("\\s+", "").trim();
// }
// }
// Path: compress/src/test/java/com/switchfly/compress/compressor/YuiJsCompressorIntegrationTest.java
import com.switchfly.compress.TestingUtil;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.compress.compressor;
public class YuiJsCompressorIntegrationTest {
@Test
public void testCompress() throws Exception {
YuiJsCompressor packager = new YuiJsCompressor();
|
String source = TestingUtil.readFile(getClass(), "uncompressed.js.txt");
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/CurrencyCodeValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/CurrencyCodeSanitizer.java
// public class CurrencyCodeSanitizer implements Sanitizer<String> {
// private static final Logger _logger = Logger.getLogger(CobrandNameSanitizer.class);
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// try {
// return Currency.getInstance(StringUtils.upperCase(content)).toString();
// } catch (Exception e) {
// HtmlSanitizer htmlSanitizer = new HtmlSanitizer();
// String sanitized = htmlSanitizer.execute(content);
// _logger.warn("Invalid currency code (" + sanitized + "). Setting currency code to \"USD\".");
// return "USD";
// }
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.CurrencyCodeSanitizer;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class CurrencyCodeValidationStrategy extends ValidationStrategy<String> {
public CurrencyCodeValidationStrategy() {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/CurrencyCodeSanitizer.java
// public class CurrencyCodeSanitizer implements Sanitizer<String> {
// private static final Logger _logger = Logger.getLogger(CobrandNameSanitizer.class);
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// try {
// return Currency.getInstance(StringUtils.upperCase(content)).toString();
// } catch (Exception e) {
// HtmlSanitizer htmlSanitizer = new HtmlSanitizer();
// String sanitized = htmlSanitizer.execute(content);
// _logger.warn("Invalid currency code (" + sanitized + "). Setting currency code to \"USD\".");
// return "USD";
// }
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/CurrencyCodeValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.CurrencyCodeSanitizer;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class CurrencyCodeValidationStrategy extends ValidationStrategy<String> {
public CurrencyCodeValidationStrategy() {
|
super(new HtmlAndQueryStringCanonicalizer(), null, new CurrencyCodeSanitizer());
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/CurrencyCodeValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/CurrencyCodeSanitizer.java
// public class CurrencyCodeSanitizer implements Sanitizer<String> {
// private static final Logger _logger = Logger.getLogger(CobrandNameSanitizer.class);
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// try {
// return Currency.getInstance(StringUtils.upperCase(content)).toString();
// } catch (Exception e) {
// HtmlSanitizer htmlSanitizer = new HtmlSanitizer();
// String sanitized = htmlSanitizer.execute(content);
// _logger.warn("Invalid currency code (" + sanitized + "). Setting currency code to \"USD\".");
// return "USD";
// }
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.CurrencyCodeSanitizer;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class CurrencyCodeValidationStrategy extends ValidationStrategy<String> {
public CurrencyCodeValidationStrategy() {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/CurrencyCodeSanitizer.java
// public class CurrencyCodeSanitizer implements Sanitizer<String> {
// private static final Logger _logger = Logger.getLogger(CobrandNameSanitizer.class);
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// try {
// return Currency.getInstance(StringUtils.upperCase(content)).toString();
// } catch (Exception e) {
// HtmlSanitizer htmlSanitizer = new HtmlSanitizer();
// String sanitized = htmlSanitizer.execute(content);
// _logger.warn("Invalid currency code (" + sanitized + "). Setting currency code to \"USD\".");
// return "USD";
// }
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/CurrencyCodeValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.CurrencyCodeSanitizer;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class CurrencyCodeValidationStrategy extends ValidationStrategy<String> {
public CurrencyCodeValidationStrategy() {
|
super(new HtmlAndQueryStringCanonicalizer(), null, new CurrencyCodeSanitizer());
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/UrlStripHtmlSanitizer.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/ValidationStrategy.java
// public class ValidationStrategy<O> {
//
// public static final ValidationStrategy<String> DEFAULT_WEB_CONTENT_VALIDATION = new WebContentValidationStrategy();
// public static final ValidationStrategy<String> CLEAN_CURRENCY_CODE = new CurrencyCodeValidationStrategy();
// public static final ValidationStrategy<String> CLEAN_LOCALE_CODE = new LocaleCodeValidationStrategy();
// public static final ValidationStrategy<String> CLEAN_URL = new UrlCleanValidationStrategy();
//
// public static final ValidationStrategies COBRAND_NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\-_]+");
// public static final ValidationStrategies ADDRESS_LINE = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\.\\-\\s#&',:\\/\\\\]+");
// public static final ValidationStrategies NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}_\\.\\-\\s~,'`]+");
// public static final ValidationStrategies PROPERTY_NAME = ValidationStrategyBuilder.withPattern("[\\w\\d\\-\\._]+");
//
// private final Canonicalizer<O> _canonicalizer;
// private final Validator<O> _validator;
// private final Sanitizer<O> _sanitizer;
//
// public ValidationStrategy(Canonicalizer<O> canonicalizer, Validator<O> validator, Sanitizer<O> sanitizer) {
// _canonicalizer = canonicalizer;
// _validator = validator;
// _sanitizer = sanitizer;
// }
//
// public final Canonicalizer<O> getCanonicalizer() {
// return _canonicalizer;
// }
//
// public final Validator<O> getValidator() {
// return _validator;
// }
//
// public final Sanitizer<O> getSanitizer() {
// return _sanitizer;
// }
//
// public final O validate(O content) {
// O canonicalized = null;
// try {
// canonicalized = _canonicalizer != null ? _canonicalizer.execute(content) : content;
// } catch (Exception e) {
// throw new ValidatorException("", "Failed to canonicalize content.");
// }
// if (_validator != null && !_validator.execute(canonicalized)) {
// throw StringUtils.isBlank(_validator.getErrorMessage()) ? new ValidatorException(canonicalized.toString()) :
// new ValidatorException(canonicalized.toString(), _validator.getErrorMessage());
// }
// try {
// return _sanitizer != null ? _sanitizer.execute(canonicalized) : canonicalized;
// } catch (Exception e) {
// throw new ValidatorException("", "Failed to sanitize content.");
// }
// }
// }
|
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import com.switchfly.inputvalidation.ValidationStrategy;
import org.apache.commons.lang.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URIUtils;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
|
String queryString = cleanedPairs.isEmpty() ? null : URLEncodedUtils.format(cleanedPairs, ENCODING);
try {
return URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), uri.getPath(), queryString, uri.getFragment()).toString();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
public static List<NameValuePair> parse(URI uri) {
final String query = uri.getRawQuery();
return parse(query);
}
public static List<NameValuePair> parse(String queryString) {
List<NameValuePair> result = Collections.emptyList();
if (queryString != null && queryString.length() > 0) {
result = new ArrayList<NameValuePair>();
parse(result, new Scanner(queryString));
}
return result;
}
private static void parse(List<NameValuePair> parameters, Scanner scanner) {
scanner.useDelimiter(PARAMETER_SEPARATOR);
while (scanner.hasNext()) {
String[] nameValue = scanner.next().split(NAME_VALUE_SEPARATOR, 2);
if (nameValue.length == 0 || nameValue.length > 2) {
throw new IllegalArgumentException("bad parameter");
}
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/ValidationStrategy.java
// public class ValidationStrategy<O> {
//
// public static final ValidationStrategy<String> DEFAULT_WEB_CONTENT_VALIDATION = new WebContentValidationStrategy();
// public static final ValidationStrategy<String> CLEAN_CURRENCY_CODE = new CurrencyCodeValidationStrategy();
// public static final ValidationStrategy<String> CLEAN_LOCALE_CODE = new LocaleCodeValidationStrategy();
// public static final ValidationStrategy<String> CLEAN_URL = new UrlCleanValidationStrategy();
//
// public static final ValidationStrategies COBRAND_NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\-_]+");
// public static final ValidationStrategies ADDRESS_LINE = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}\\.\\-\\s#&',:\\/\\\\]+");
// public static final ValidationStrategies NAME = ValidationStrategyBuilder.withPattern("[\\p{L}\\p{Nd}_\\.\\-\\s~,'`]+");
// public static final ValidationStrategies PROPERTY_NAME = ValidationStrategyBuilder.withPattern("[\\w\\d\\-\\._]+");
//
// private final Canonicalizer<O> _canonicalizer;
// private final Validator<O> _validator;
// private final Sanitizer<O> _sanitizer;
//
// public ValidationStrategy(Canonicalizer<O> canonicalizer, Validator<O> validator, Sanitizer<O> sanitizer) {
// _canonicalizer = canonicalizer;
// _validator = validator;
// _sanitizer = sanitizer;
// }
//
// public final Canonicalizer<O> getCanonicalizer() {
// return _canonicalizer;
// }
//
// public final Validator<O> getValidator() {
// return _validator;
// }
//
// public final Sanitizer<O> getSanitizer() {
// return _sanitizer;
// }
//
// public final O validate(O content) {
// O canonicalized = null;
// try {
// canonicalized = _canonicalizer != null ? _canonicalizer.execute(content) : content;
// } catch (Exception e) {
// throw new ValidatorException("", "Failed to canonicalize content.");
// }
// if (_validator != null && !_validator.execute(canonicalized)) {
// throw StringUtils.isBlank(_validator.getErrorMessage()) ? new ValidatorException(canonicalized.toString()) :
// new ValidatorException(canonicalized.toString(), _validator.getErrorMessage());
// }
// try {
// return _sanitizer != null ? _sanitizer.execute(canonicalized) : canonicalized;
// } catch (Exception e) {
// throw new ValidatorException("", "Failed to sanitize content.");
// }
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/UrlStripHtmlSanitizer.java
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import com.switchfly.inputvalidation.ValidationStrategy;
import org.apache.commons.lang.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.client.utils.URIUtils;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
String queryString = cleanedPairs.isEmpty() ? null : URLEncodedUtils.format(cleanedPairs, ENCODING);
try {
return URIUtils.createURI(uri.getScheme(), uri.getHost(), uri.getPort(), uri.getPath(), queryString, uri.getFragment()).toString();
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
public static List<NameValuePair> parse(URI uri) {
final String query = uri.getRawQuery();
return parse(query);
}
public static List<NameValuePair> parse(String queryString) {
List<NameValuePair> result = Collections.emptyList();
if (queryString != null && queryString.length() > 0) {
result = new ArrayList<NameValuePair>();
parse(result, new Scanner(queryString));
}
return result;
}
private static void parse(List<NameValuePair> parameters, Scanner scanner) {
scanner.useDelimiter(PARAMETER_SEPARATOR);
while (scanner.hasNext()) {
String[] nameValue = scanner.next().split(NAME_VALUE_SEPARATOR, 2);
if (nameValue.length == 0 || nameValue.length > 2) {
throw new IllegalArgumentException("bad parameter");
}
|
String name = ValidationStrategy.PROPERTY_NAME.cleanStrategy().validate(nameValue[0]);
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/RequestParameter.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
|
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class RequestParameter extends Parameter<String> {
public RequestParameter(String name, String value) {
super(name, value);
validateWith(ValidationStrategy.DEFAULT_WEB_CONTENT_VALIDATION);
}
public boolean isBlank() {
return StringUtils.isBlank(getValue());
}
@Override
public boolean isEmpty() {
return isBlank();
}
@Override
public RequestParameter validateWith(ValidationStrategy<String> validationStrategy) {
super.validateWith(validationStrategy);
return this;
}
@Override
public String toString() {
return validate();
}
public String toString(String defaultValue) {
return validate(defaultValue);
}
public Double toDouble() {
String value = toString();
try {
return Double.parseDouble(value);
} catch (NumberFormatException e) {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/RequestParameter.java
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class RequestParameter extends Parameter<String> {
public RequestParameter(String name, String value) {
super(name, value);
validateWith(ValidationStrategy.DEFAULT_WEB_CONTENT_VALIDATION);
}
public boolean isBlank() {
return StringUtils.isBlank(getValue());
}
@Override
public boolean isEmpty() {
return isBlank();
}
@Override
public RequestParameter validateWith(ValidationStrategy<String> validationStrategy) {
super.validateWith(validationStrategy);
return this;
}
@Override
public String toString() {
return validate();
}
public String toString(String defaultValue) {
return validate(defaultValue);
}
public Double toDouble() {
String value = toString();
try {
return Double.parseDouble(value);
} catch (NumberFormatException e) {
|
throw new InvalidRequestParameterException(getName(), value);
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/RequestParameter.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
|
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
|
@Override
public RequestParameter validateWith(ValidationStrategy<String> validationStrategy) {
super.validateWith(validationStrategy);
return this;
}
@Override
public String toString() {
return validate();
}
public String toString(String defaultValue) {
return validate(defaultValue);
}
public Double toDouble() {
String value = toString();
try {
return Double.parseDouble(value);
} catch (NumberFormatException e) {
throw new InvalidRequestParameterException(getName(), value);
}
}
public Double toDouble(double defaultValue) {
try {
return toDouble();
} catch (InvalidRequestParameterException e) {
return defaultValue;
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/InvalidRequestParameterException.java
// public class InvalidRequestParameterException extends MissingRequestParameterException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterValue;
//
// public InvalidRequestParameterException(String parameterName, String parameterValue) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue);
// _parameterValue = parameterValue;
// }
//
// public InvalidRequestParameterException(String parameterName, String parameterValue, Throwable cause) {
// super(parameterName, "Invalid request parameter: " + parameterName + " = " + parameterValue, cause);
// _parameterValue = parameterValue;
// }
//
// public String getParameterValue() {
// return _parameterValue;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/MissingRequestParameterException.java
// public class MissingRequestParameterException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
// private final String _parameterName;
//
// public MissingRequestParameterException(String parameterName) {
// super("Missing request parameter: " + parameterName + ".");
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message) {
// super(message);
// _parameterName = parameterName;
// }
//
// public MissingRequestParameterException(String parameterName, String message, Throwable cause) {
// super(message, cause);
// _parameterName = parameterName;
// }
//
// public String getParameterName() {
// return _parameterName;
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/RequestParameter.java
import com.switchfly.inputvalidation.exception.InvalidRequestParameterException;
import com.switchfly.inputvalidation.exception.MissingRequestParameterException;
import org.apache.commons.lang.BooleanUtils;
import org.apache.commons.lang.StringUtils;
@Override
public RequestParameter validateWith(ValidationStrategy<String> validationStrategy) {
super.validateWith(validationStrategy);
return this;
}
@Override
public String toString() {
return validate();
}
public String toString(String defaultValue) {
return validate(defaultValue);
}
public Double toDouble() {
String value = toString();
try {
return Double.parseDouble(value);
} catch (NumberFormatException e) {
throw new InvalidRequestParameterException(getName(), value);
}
}
public Double toDouble(double defaultValue) {
try {
return toDouble();
} catch (InvalidRequestParameterException e) {
return defaultValue;
|
} catch (MissingRequestParameterException e) {
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/LocaleCodeValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/LocaleCodeSanitizer.java
// public class LocaleCodeSanitizer implements Sanitizer<String> {
// private static final Logger _logger = Logger.getLogger(CobrandNameSanitizer.class);
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Locale locale;
// try {
// locale = LocaleUtils.toLocale(content);
// } catch (Exception e) {
// return getDefaultLocale(content);
// }
// if (!Arrays.asList(Locale.getAvailableLocales()).contains(locale)) {
// return getDefaultLocale(content);
// }
// return locale.toString();
// }
//
// private String getDefaultLocale(String content) {
// String sanitized = new HtmlSanitizer().execute(content);
// _logger.warn("Invalid locale code (" + sanitized + "). Setting locale code to \"en_US\".");
// return Locale.US.toString();
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.LocaleCodeSanitizer;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class LocaleCodeValidationStrategy extends ValidationStrategy<String> {
public LocaleCodeValidationStrategy() {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/LocaleCodeSanitizer.java
// public class LocaleCodeSanitizer implements Sanitizer<String> {
// private static final Logger _logger = Logger.getLogger(CobrandNameSanitizer.class);
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Locale locale;
// try {
// locale = LocaleUtils.toLocale(content);
// } catch (Exception e) {
// return getDefaultLocale(content);
// }
// if (!Arrays.asList(Locale.getAvailableLocales()).contains(locale)) {
// return getDefaultLocale(content);
// }
// return locale.toString();
// }
//
// private String getDefaultLocale(String content) {
// String sanitized = new HtmlSanitizer().execute(content);
// _logger.warn("Invalid locale code (" + sanitized + "). Setting locale code to \"en_US\".");
// return Locale.US.toString();
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/LocaleCodeValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.LocaleCodeSanitizer;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class LocaleCodeValidationStrategy extends ValidationStrategy<String> {
public LocaleCodeValidationStrategy() {
|
super(new HtmlAndQueryStringCanonicalizer(), null, new LocaleCodeSanitizer());
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/LocaleCodeValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/LocaleCodeSanitizer.java
// public class LocaleCodeSanitizer implements Sanitizer<String> {
// private static final Logger _logger = Logger.getLogger(CobrandNameSanitizer.class);
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Locale locale;
// try {
// locale = LocaleUtils.toLocale(content);
// } catch (Exception e) {
// return getDefaultLocale(content);
// }
// if (!Arrays.asList(Locale.getAvailableLocales()).contains(locale)) {
// return getDefaultLocale(content);
// }
// return locale.toString();
// }
//
// private String getDefaultLocale(String content) {
// String sanitized = new HtmlSanitizer().execute(content);
// _logger.warn("Invalid locale code (" + sanitized + "). Setting locale code to \"en_US\".");
// return Locale.US.toString();
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.LocaleCodeSanitizer;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class LocaleCodeValidationStrategy extends ValidationStrategy<String> {
public LocaleCodeValidationStrategy() {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/HtmlAndQueryStringCanonicalizer.java
// public class HtmlAndQueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = StringEscapeUtils.unescapeHtml(s);
// } catch (Exception e) {
// throw new IllegalArgumentException("Canonicalization error", e);
// }
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// // ignore and move on
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/sanitizer/LocaleCodeSanitizer.java
// public class LocaleCodeSanitizer implements Sanitizer<String> {
// private static final Logger _logger = Logger.getLogger(CobrandNameSanitizer.class);
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// Locale locale;
// try {
// locale = LocaleUtils.toLocale(content);
// } catch (Exception e) {
// return getDefaultLocale(content);
// }
// if (!Arrays.asList(Locale.getAvailableLocales()).contains(locale)) {
// return getDefaultLocale(content);
// }
// return locale.toString();
// }
//
// private String getDefaultLocale(String content) {
// String sanitized = new HtmlSanitizer().execute(content);
// _logger.warn("Invalid locale code (" + sanitized + "). Setting locale code to \"en_US\".");
// return Locale.US.toString();
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/LocaleCodeValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.HtmlAndQueryStringCanonicalizer;
import com.switchfly.inputvalidation.sanitizer.LocaleCodeSanitizer;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class LocaleCodeValidationStrategy extends ValidationStrategy<String> {
public LocaleCodeValidationStrategy() {
|
super(new HtmlAndQueryStringCanonicalizer(), null, new LocaleCodeSanitizer());
|
switchfly/switchfly-java
|
compress/src/test/java/com/switchfly/compress/cli/CompressCLITest.java
|
// Path: compress/src/test/java/com/switchfly/compress/TestingUtil.java
// public class TestingUtil {
//
// public static String readFile(Class clazz, String resource) throws IOException {
// return IOUtils.toString(clazz.getResourceAsStream(resource));
// }
//
// public static void assertEqualsIgnoreWhitespace(String expected, String actual) {
// if (normalizeWhiteSpace(expected).equals(normalizeWhiteSpace(actual))) {
// return;
// }
// assertEquals(expected, actual);
// }
//
// // Trim and replace any white space between characters, newlines, carriage returns, etc. with one space " \t ab c" => " ab c"
// // Good for maintaining space for XML documents, if you used equalsIgnoreWhiteSpace it would make "a href" => "ahref"
// public static String normalizeWhiteSpace(String s) {
// return s.replaceAll("\\s+", "").trim();
// }
// }
|
import java.io.File;
import java.io.FileInputStream;
import com.switchfly.compress.TestingUtil;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
|
compressCLI.setDisableMicroOptimizations(false);
compressCLI.setPreserveUnecessarySemicolons(true);
compressCLI.setOutputPath(_outputLocation.getAbsolutePath());
compressCLI.setConfigurationFromString(_configuration);
compressCLI.setBaseInputPath(_inputLocation.getAbsolutePath());
compressCLI.setJsURIFragment("/js");
compressCLI.setCssURIFragment("/css");
compressCLI.execute();
File cssDir = new File(_outputLocation, "css");
assertTrue(cssDir.exists());
assertEquals(4, cssDir.listFiles().length);
File jsDir = new File(_outputLocation, "js");
assertTrue(jsDir.exists());
assertEquals(4, jsDir.listFiles().length);
}
@Test
public void testMinifyAndObfuscateCss() throws Exception {
File input = new File(getClass().getResource("input.css").getFile());
CompressCLI compressCLI = new CompressCLI();
compressCLI.minifyAndObfuscateFile(input, _outputFile, false);
assertTrue(_outputFile.exists());
String actual = IOUtils.toString(new FileInputStream(_outputFile));
String expected = IOUtils.toString(getClass().getResourceAsStream("inputMinified.css")).trim();
|
// Path: compress/src/test/java/com/switchfly/compress/TestingUtil.java
// public class TestingUtil {
//
// public static String readFile(Class clazz, String resource) throws IOException {
// return IOUtils.toString(clazz.getResourceAsStream(resource));
// }
//
// public static void assertEqualsIgnoreWhitespace(String expected, String actual) {
// if (normalizeWhiteSpace(expected).equals(normalizeWhiteSpace(actual))) {
// return;
// }
// assertEquals(expected, actual);
// }
//
// // Trim and replace any white space between characters, newlines, carriage returns, etc. with one space " \t ab c" => " ab c"
// // Good for maintaining space for XML documents, if you used equalsIgnoreWhiteSpace it would make "a href" => "ahref"
// public static String normalizeWhiteSpace(String s) {
// return s.replaceAll("\\s+", "").trim();
// }
// }
// Path: compress/src/test/java/com/switchfly/compress/cli/CompressCLITest.java
import java.io.File;
import java.io.FileInputStream;
import com.switchfly.compress.TestingUtil;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
compressCLI.setDisableMicroOptimizations(false);
compressCLI.setPreserveUnecessarySemicolons(true);
compressCLI.setOutputPath(_outputLocation.getAbsolutePath());
compressCLI.setConfigurationFromString(_configuration);
compressCLI.setBaseInputPath(_inputLocation.getAbsolutePath());
compressCLI.setJsURIFragment("/js");
compressCLI.setCssURIFragment("/css");
compressCLI.execute();
File cssDir = new File(_outputLocation, "css");
assertTrue(cssDir.exists());
assertEquals(4, cssDir.listFiles().length);
File jsDir = new File(_outputLocation, "js");
assertTrue(jsDir.exists());
assertEquals(4, jsDir.listFiles().length);
}
@Test
public void testMinifyAndObfuscateCss() throws Exception {
File input = new File(getClass().getResource("input.css").getFile());
CompressCLI compressCLI = new CompressCLI();
compressCLI.minifyAndObfuscateFile(input, _outputFile, false);
assertTrue(_outputFile.exists());
String actual = IOUtils.toString(new FileInputStream(_outputFile));
String expected = IOUtils.toString(getClass().getResourceAsStream("inputMinified.css")).trim();
|
TestingUtil.assertEqualsIgnoreWhitespace(expected, actual.trim());
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/UrlValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/QueryStringCanonicalizer.java
// public class QueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/UrlValidator.java
// public class UrlValidator extends Validator<String> {
//
// @Override
// public boolean execute(String content) {
// if (StringUtils.isBlank(content)) {
// return false;
// }
// String[] schemes = {"http", "https"};
// org.apache.commons.validator.UrlValidator urlValidator =
// new org.apache.commons.validator.UrlValidator(schemes, org.apache.commons.validator.UrlValidator.ALLOW_2_SLASHES);
//
// if (content.startsWith("http")) {
// return urlValidator.isValid(content);
// }
//
// return execute("http://www.mock.com/" + content);
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.QueryStringCanonicalizer;
import com.switchfly.inputvalidation.validator.UrlValidator;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class UrlValidationStrategy extends ValidationStrategy<String> {
public UrlValidationStrategy() {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/QueryStringCanonicalizer.java
// public class QueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/UrlValidator.java
// public class UrlValidator extends Validator<String> {
//
// @Override
// public boolean execute(String content) {
// if (StringUtils.isBlank(content)) {
// return false;
// }
// String[] schemes = {"http", "https"};
// org.apache.commons.validator.UrlValidator urlValidator =
// new org.apache.commons.validator.UrlValidator(schemes, org.apache.commons.validator.UrlValidator.ALLOW_2_SLASHES);
//
// if (content.startsWith("http")) {
// return urlValidator.isValid(content);
// }
//
// return execute("http://www.mock.com/" + content);
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/UrlValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.QueryStringCanonicalizer;
import com.switchfly.inputvalidation.validator.UrlValidator;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class UrlValidationStrategy extends ValidationStrategy<String> {
public UrlValidationStrategy() {
|
super(new QueryStringCanonicalizer(), new UrlValidator(), null);
|
switchfly/switchfly-java
|
inputvalidation/src/main/java/com/switchfly/inputvalidation/UrlValidationStrategy.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/QueryStringCanonicalizer.java
// public class QueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/UrlValidator.java
// public class UrlValidator extends Validator<String> {
//
// @Override
// public boolean execute(String content) {
// if (StringUtils.isBlank(content)) {
// return false;
// }
// String[] schemes = {"http", "https"};
// org.apache.commons.validator.UrlValidator urlValidator =
// new org.apache.commons.validator.UrlValidator(schemes, org.apache.commons.validator.UrlValidator.ALLOW_2_SLASHES);
//
// if (content.startsWith("http")) {
// return urlValidator.isValid(content);
// }
//
// return execute("http://www.mock.com/" + content);
// }
// }
|
import com.switchfly.inputvalidation.canonicalizer.QueryStringCanonicalizer;
import com.switchfly.inputvalidation.validator.UrlValidator;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class UrlValidationStrategy extends ValidationStrategy<String> {
public UrlValidationStrategy() {
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/canonicalizer/QueryStringCanonicalizer.java
// public class QueryStringCanonicalizer extends StringCanonicalizer {
//
// @Override
// public String execute(String content) {
// if (StringUtils.isBlank(content)) {
// return content;
// }
// String s = super.execute(content);
// try {
// s = URLDecoder.decode(s, "UTF-8");
// } catch (Exception e) {
// throw new RuntimeException(e);
// }
// return s;
// }
// }
//
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/validator/UrlValidator.java
// public class UrlValidator extends Validator<String> {
//
// @Override
// public boolean execute(String content) {
// if (StringUtils.isBlank(content)) {
// return false;
// }
// String[] schemes = {"http", "https"};
// org.apache.commons.validator.UrlValidator urlValidator =
// new org.apache.commons.validator.UrlValidator(schemes, org.apache.commons.validator.UrlValidator.ALLOW_2_SLASHES);
//
// if (content.startsWith("http")) {
// return urlValidator.isValid(content);
// }
//
// return execute("http://www.mock.com/" + content);
// }
// }
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/UrlValidationStrategy.java
import com.switchfly.inputvalidation.canonicalizer.QueryStringCanonicalizer;
import com.switchfly.inputvalidation.validator.UrlValidator;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.inputvalidation;
public class UrlValidationStrategy extends ValidationStrategy<String> {
public UrlValidationStrategy() {
|
super(new QueryStringCanonicalizer(), new UrlValidator(), null);
|
switchfly/switchfly-java
|
inputvalidation/src/test/java/com/switchfly/inputvalidation/NameValidationStrategiesTest.java
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
|
import com.switchfly.inputvalidation.exception.ValidatorException;
import org.junit.Test;
import static org.junit.Assert.*;
|
assertValidationException("!", validationStrategy);
assertValidationException("/", validationStrategy);
assertValidationException("(", validationStrategy);
assertValidationException(")", validationStrategy);
assertValidationException("$", validationStrategy);
assertValidationException("&", validationStrategy);
assertValidationException("%", validationStrategy);
assertValidationException("#", validationStrategy);
assertValidationException("<", validationStrategy);
assertValidationException(">", validationStrategy);
assertValidationException("^", validationStrategy);
assertValidationException("*", validationStrategy);
assertValidationException("=", validationStrategy);
assertValidationException("{", validationStrategy);
assertValidationException("}", validationStrategy);
assertValidationException("[", validationStrategy);
assertValidationException("]", validationStrategy);
assertValidationException("\"", validationStrategy);
assertValidationException("1\" +onmouseover=alert(\"123123\") +", validationStrategy);
assertValidationException("1\"+onmouseover=alert(\"123123\")+", validationStrategy);
assertValidationException("1'+onmouseover=alert('123123')+", validationStrategy);
assertValidationException("1'onmouseover=alert('123123')", validationStrategy);
assertValidationException("1'onmouseover=alert(123123)", validationStrategy);
}
public static void assertValidationException(String html, ValidationStrategy<String> validationStrategy) {
try {
validationStrategy.validate(html);
fail("content should not be valid.");
|
// Path: inputvalidation/src/main/java/com/switchfly/inputvalidation/exception/ValidatorException.java
// public class ValidatorException extends RuntimeException {
// private static final long serialVersionUID = 1L;
// private final String _sanitizedContent;
//
// public ValidatorException(String sanitizedContent) {
// _sanitizedContent = sanitizedContent;
// }
//
// public ValidatorException(String sanitizedContent, String message) {
// super(message);
// _sanitizedContent = sanitizedContent;
// }
//
// public String getSanitizedContent() {
// return _sanitizedContent;
// }
// }
// Path: inputvalidation/src/test/java/com/switchfly/inputvalidation/NameValidationStrategiesTest.java
import com.switchfly.inputvalidation.exception.ValidatorException;
import org.junit.Test;
import static org.junit.Assert.*;
assertValidationException("!", validationStrategy);
assertValidationException("/", validationStrategy);
assertValidationException("(", validationStrategy);
assertValidationException(")", validationStrategy);
assertValidationException("$", validationStrategy);
assertValidationException("&", validationStrategy);
assertValidationException("%", validationStrategy);
assertValidationException("#", validationStrategy);
assertValidationException("<", validationStrategy);
assertValidationException(">", validationStrategy);
assertValidationException("^", validationStrategy);
assertValidationException("*", validationStrategy);
assertValidationException("=", validationStrategy);
assertValidationException("{", validationStrategy);
assertValidationException("}", validationStrategy);
assertValidationException("[", validationStrategy);
assertValidationException("]", validationStrategy);
assertValidationException("\"", validationStrategy);
assertValidationException("1\" +onmouseover=alert(\"123123\") +", validationStrategy);
assertValidationException("1\"+onmouseover=alert(\"123123\")+", validationStrategy);
assertValidationException("1'+onmouseover=alert('123123')+", validationStrategy);
assertValidationException("1'onmouseover=alert('123123')", validationStrategy);
assertValidationException("1'onmouseover=alert(123123)", validationStrategy);
}
public static void assertValidationException(String html, ValidationStrategy<String> validationStrategy) {
try {
validationStrategy.validate(html);
fail("content should not be valid.");
|
} catch (ValidatorException e) {
|
switchfly/switchfly-java
|
compress/src/test/java/com/switchfly/compress/compressor/YuiCssCompressorTest.java
|
// Path: compress/src/test/java/com/switchfly/compress/TestingUtil.java
// public class TestingUtil {
//
// public static String readFile(Class clazz, String resource) throws IOException {
// return IOUtils.toString(clazz.getResourceAsStream(resource));
// }
//
// public static void assertEqualsIgnoreWhitespace(String expected, String actual) {
// if (normalizeWhiteSpace(expected).equals(normalizeWhiteSpace(actual))) {
// return;
// }
// assertEquals(expected, actual);
// }
//
// // Trim and replace any white space between characters, newlines, carriage returns, etc. with one space " \t ab c" => " ab c"
// // Good for maintaining space for XML documents, if you used equalsIgnoreWhiteSpace it would make "a href" => "ahref"
// public static String normalizeWhiteSpace(String s) {
// return s.replaceAll("\\s+", "").trim();
// }
// }
|
import com.switchfly.compress.TestingUtil;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
|
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.compress.compressor;
public class YuiCssCompressorTest {
@Test
public void testCompress() throws Exception {
|
// Path: compress/src/test/java/com/switchfly/compress/TestingUtil.java
// public class TestingUtil {
//
// public static String readFile(Class clazz, String resource) throws IOException {
// return IOUtils.toString(clazz.getResourceAsStream(resource));
// }
//
// public static void assertEqualsIgnoreWhitespace(String expected, String actual) {
// if (normalizeWhiteSpace(expected).equals(normalizeWhiteSpace(actual))) {
// return;
// }
// assertEquals(expected, actual);
// }
//
// // Trim and replace any white space between characters, newlines, carriage returns, etc. with one space " \t ab c" => " ab c"
// // Good for maintaining space for XML documents, if you used equalsIgnoreWhiteSpace it would make "a href" => "ahref"
// public static String normalizeWhiteSpace(String s) {
// return s.replaceAll("\\s+", "").trim();
// }
// }
// Path: compress/src/test/java/com/switchfly/compress/compressor/YuiCssCompressorTest.java
import com.switchfly.compress.TestingUtil;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/*
* Copyright 2012 Switchfly
*
* Licensed 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 com.switchfly.compress.compressor;
public class YuiCssCompressorTest {
@Test
public void testCompress() throws Exception {
|
String uncompressed = TestingUtil.readFile(getClass(), "uncompressed.css.txt");
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethodTest.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethod.java
// public enum VerificationStatus {EXPIRED, FAILED, UNDER_REVIEW, VERIFIED, REQUIRED, NOT_REQUIRED, READY_FOR_REVIEW, REQUESTED}
|
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.VerificationStatus;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
|
.businessName("test-business-name")
.businessOperatingName("test-business-operating-name")
.businessRegistrationId("test-business-registration-id")
.businessRegistrationStateProvince("test-business-registration-state-province")
.businessRegistrationCountry("test-business-registration-country")
.businessContactRole(HyperwalletUser.BusinessContactRole.OWNER)
.firstName("test-first-name")
.middleName("test-middle-name")
.lastName("test-last-name")
.dateOfBirth(new Date())
.countryOfBirth("test-country-of-birth")
.countryOfNationality("test-country-of-nationality")
.gender(HyperwalletUser.Gender.MALE)
.phoneNumber("test-phone-number")
.mobileNumber("test-mobile-number")
.email("test-email")
.governmentId("test-government-id")
.passportId("test-passport-id")
.driversLicenseId("test-drivers-license-id")
.addressLine1("test-address-line1")
.addressLine2("test-address-line2")
.city("test-city")
.stateProvince("test-state-province")
.postalCode("test-postal-code")
.country("test-country")
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethod.java
// public enum VerificationStatus {EXPIRED, FAILED, UNDER_REVIEW, VERIFIED, REQUIRED, NOT_REQUIRED, READY_FOR_REVIEW, REQUESTED}
// Path: src/test/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethodTest.java
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.VerificationStatus;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
.businessName("test-business-name")
.businessOperatingName("test-business-operating-name")
.businessRegistrationId("test-business-registration-id")
.businessRegistrationStateProvince("test-business-registration-state-province")
.businessRegistrationCountry("test-business-registration-country")
.businessContactRole(HyperwalletUser.BusinessContactRole.OWNER)
.firstName("test-first-name")
.middleName("test-middle-name")
.lastName("test-last-name")
.dateOfBirth(new Date())
.countryOfBirth("test-country-of-birth")
.countryOfNationality("test-country-of-nationality")
.gender(HyperwalletUser.Gender.MALE)
.phoneNumber("test-phone-number")
.mobileNumber("test-mobile-number")
.email("test-email")
.governmentId("test-government-id")
.passportId("test-passport-id")
.driversLicenseId("test-drivers-license-id")
.addressLine1("test-address-line1")
.addressLine2("test-address-line2")
.city("test-city")
.stateProvince("test-state-province")
.postalCode("test-postal-code")
.country("test-country")
|
.verificationStatus(VerificationStatus.NOT_REQUIRED)
|
hyperwallet/java-sdk
|
src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferRefund.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransfer.java
// public static class ForeignExchange {
//
// private Double sourceAmount;
// private String sourceCurrency;
// private Double destinationAmount;
// private String destinationCurrency;
// private Double rate;
//
// public Double getSourceAmount() {
// return sourceAmount;
// }
//
// public void setSourceAmount(Double sourceAmount) {
// this.sourceAmount = sourceAmount;
// }
//
// public String getSourceCurrency() {
// return sourceCurrency;
// }
//
// public void setSourceCurrency(String sourceCurrency) {
// this.sourceCurrency = sourceCurrency;
// }
//
// public Double getDestinationAmount() {
// return destinationAmount;
// }
//
// public void setDestinationAmount(Double destinationAmount) {
// this.destinationAmount = destinationAmount;
// }
//
// public String getDestinationCurrency() {
// return destinationCurrency;
// }
//
// public void setDestinationCurrency(String destinationCurrency) {
// this.destinationCurrency = destinationCurrency;
// }
//
// public Double getRate() {
// return rate;
// }
//
// public void setRate(Double rate) {
// this.rate = rate;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/util/HyperwalletJsonConfiguration.java
// public class HyperwalletJsonConfiguration {
//
// public static final String INCLUSION_FILTER = "inclusion-filter";
// private ObjectMapper objectMapper;
// private ObjectMapper parsingObjectMapper;
//
// HyperwalletJsonConfiguration() {
// DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
// dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
//
// this.objectMapper = new ObjectMapper()
// .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true)
// .configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
// .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
// .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
// .configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false)
// .configure(SerializationFeature.WRITE_ENUMS_USING_INDEX, false)
// .setDateFormat(dateFormat)
// .setSerializationInclusion(Include.ALWAYS);
//
// this.parsingObjectMapper = new ObjectMapper()
// .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true)
// .configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
// .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
// .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
// .configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false)
// .configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false)
// .configure(SerializationFeature.WRITE_ENUMS_USING_INDEX, false);
// }
//
// public ObjectMapper getParser() {
// return this.parsingObjectMapper;
// }
//
// public ObjectMapper getContext(final Class<?> type) {
// return objectMapper;
// }
//
//
// }
|
import com.fasterxml.jackson.annotation.JsonFilter;
import com.hyperwallet.clientsdk.model.HyperwalletTransfer.ForeignExchange;
import com.hyperwallet.clientsdk.util.HyperwalletJsonConfiguration;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;
import java.util.List;
|
package com.hyperwallet.clientsdk.model;
@JsonFilter(HyperwalletJsonConfiguration.INCLUSION_FILTER)
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class HyperwalletTransferRefund extends HyperwalletBaseMonitor {
public static enum Status {PENDING, FAILED, COMPLETED}
private String token;
private Status status;
private String clientRefundId;
private String sourceToken;
private Double sourceAmount;
private String sourceCurrency;
private String destinationToken;
private Double destinationAmount;
private String destinationCurrency;
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransfer.java
// public static class ForeignExchange {
//
// private Double sourceAmount;
// private String sourceCurrency;
// private Double destinationAmount;
// private String destinationCurrency;
// private Double rate;
//
// public Double getSourceAmount() {
// return sourceAmount;
// }
//
// public void setSourceAmount(Double sourceAmount) {
// this.sourceAmount = sourceAmount;
// }
//
// public String getSourceCurrency() {
// return sourceCurrency;
// }
//
// public void setSourceCurrency(String sourceCurrency) {
// this.sourceCurrency = sourceCurrency;
// }
//
// public Double getDestinationAmount() {
// return destinationAmount;
// }
//
// public void setDestinationAmount(Double destinationAmount) {
// this.destinationAmount = destinationAmount;
// }
//
// public String getDestinationCurrency() {
// return destinationCurrency;
// }
//
// public void setDestinationCurrency(String destinationCurrency) {
// this.destinationCurrency = destinationCurrency;
// }
//
// public Double getRate() {
// return rate;
// }
//
// public void setRate(Double rate) {
// this.rate = rate;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/util/HyperwalletJsonConfiguration.java
// public class HyperwalletJsonConfiguration {
//
// public static final String INCLUSION_FILTER = "inclusion-filter";
// private ObjectMapper objectMapper;
// private ObjectMapper parsingObjectMapper;
//
// HyperwalletJsonConfiguration() {
// DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
// dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
//
// this.objectMapper = new ObjectMapper()
// .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true)
// .configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
// .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
// .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
// .configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false)
// .configure(SerializationFeature.WRITE_ENUMS_USING_INDEX, false)
// .setDateFormat(dateFormat)
// .setSerializationInclusion(Include.ALWAYS);
//
// this.parsingObjectMapper = new ObjectMapper()
// .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true)
// .configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
// .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
// .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
// .configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false)
// .configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false)
// .configure(SerializationFeature.WRITE_ENUMS_USING_INDEX, false);
// }
//
// public ObjectMapper getParser() {
// return this.parsingObjectMapper;
// }
//
// public ObjectMapper getContext(final Class<?> type) {
// return objectMapper;
// }
//
//
// }
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferRefund.java
import com.fasterxml.jackson.annotation.JsonFilter;
import com.hyperwallet.clientsdk.model.HyperwalletTransfer.ForeignExchange;
import com.hyperwallet.clientsdk.util.HyperwalletJsonConfiguration;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Date;
import java.util.List;
package com.hyperwallet.clientsdk.model;
@JsonFilter(HyperwalletJsonConfiguration.INCLUSION_FILTER)
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class HyperwalletTransferRefund extends HyperwalletBaseMonitor {
public static enum Status {PENDING, FAILED, COMPLETED}
private String token;
private Status status;
private String clientRefundId;
private String sourceToken;
private Double sourceAmount;
private String sourceCurrency;
private String destinationToken;
private Double destinationAmount;
private String destinationCurrency;
|
private List<ForeignExchange> foreignExchanges;
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/util/HyperwalletJsonUtilTest.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBaseMonitor.java
// public class HyperwalletBaseMonitor {
//
// @JsonIgnore
// private Set<String> inclusions = new HashSet<String>();
//
// protected HyperwalletBaseMonitor() {
// }
//
// public Set<String> getInclusions() {
// return inclusions;
// }
//
// protected void addField(String field, Object o) {
// if (o == null && inclusions.contains(field)) {
// inclusions.remove(field);
// } else if (o != null) {
// inclusions.add(field);
// }
// }
//
// protected void clearField(String field) {
// inclusions.add(field);
// }
// }
|
import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.core.type.TypeReference;
import com.hyperwallet.clientsdk.HyperwalletException;
import com.hyperwallet.clientsdk.model.HyperwalletBaseMonitor;
import org.testng.annotations.Test;
import javax.xml.bind.Element;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
|
package com.hyperwallet.clientsdk.util;
/**
* @author fkrauthan
*/
public class HyperwalletJsonUtilTest {
@JsonFilter(HyperwalletJsonConfiguration.INCLUSION_FILTER)
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public static class TestBody {
public String test;
public Double amount;
}
@JsonFilter(HyperwalletJsonConfiguration.INCLUSION_FILTER)
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBaseMonitor.java
// public class HyperwalletBaseMonitor {
//
// @JsonIgnore
// private Set<String> inclusions = new HashSet<String>();
//
// protected HyperwalletBaseMonitor() {
// }
//
// public Set<String> getInclusions() {
// return inclusions;
// }
//
// protected void addField(String field, Object o) {
// if (o == null && inclusions.contains(field)) {
// inclusions.remove(field);
// } else if (o != null) {
// inclusions.add(field);
// }
// }
//
// protected void clearField(String field) {
// inclusions.add(field);
// }
// }
// Path: src/test/java/com/hyperwallet/clientsdk/util/HyperwalletJsonUtilTest.java
import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.core.type.TypeReference;
import com.hyperwallet.clientsdk.HyperwalletException;
import com.hyperwallet.clientsdk.model.HyperwalletBaseMonitor;
import org.testng.annotations.Test;
import javax.xml.bind.Element;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
package com.hyperwallet.clientsdk.util;
/**
* @author fkrauthan
*/
public class HyperwalletJsonUtilTest {
@JsonFilter(HyperwalletJsonConfiguration.INCLUSION_FILTER)
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public static class TestBody {
public String test;
public Double amount;
}
@JsonFilter(HyperwalletJsonConfiguration.INCLUSION_FILTER)
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
|
public static class TestBodyWithMonitor extends HyperwalletBaseMonitor {
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/util/HyperwalletJsonUtilTest.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBaseMonitor.java
// public class HyperwalletBaseMonitor {
//
// @JsonIgnore
// private Set<String> inclusions = new HashSet<String>();
//
// protected HyperwalletBaseMonitor() {
// }
//
// public Set<String> getInclusions() {
// return inclusions;
// }
//
// protected void addField(String field, Object o) {
// if (o == null && inclusions.contains(field)) {
// inclusions.remove(field);
// } else if (o != null) {
// inclusions.add(field);
// }
// }
//
// protected void clearField(String field) {
// inclusions.add(field);
// }
// }
|
import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.core.type.TypeReference;
import com.hyperwallet.clientsdk.HyperwalletException;
import com.hyperwallet.clientsdk.model.HyperwalletBaseMonitor;
import org.testng.annotations.Test;
import javax.xml.bind.Element;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
|
public void clearTest3() {
clearField("test3");
this.test3 = null;
}
}
@JsonFilter(HyperwalletJsonConfiguration.INCLUSION_FILTER)
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public static class TestWithError extends HyperwalletBaseMonitor {
public Element element;
public TestWithError() {
element = new Element() {
};
addField("element", element);
}
}
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testInstanceCreation() {
new HyperwalletJsonUtil();
}
@Test
public void testFromJson_byClassReference_nullContent() {
TestBody body = HyperwalletJsonUtil.fromJson(null, TestBody.class);
assertThat(body, is(nullValue()));
}
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBaseMonitor.java
// public class HyperwalletBaseMonitor {
//
// @JsonIgnore
// private Set<String> inclusions = new HashSet<String>();
//
// protected HyperwalletBaseMonitor() {
// }
//
// public Set<String> getInclusions() {
// return inclusions;
// }
//
// protected void addField(String field, Object o) {
// if (o == null && inclusions.contains(field)) {
// inclusions.remove(field);
// } else if (o != null) {
// inclusions.add(field);
// }
// }
//
// protected void clearField(String field) {
// inclusions.add(field);
// }
// }
// Path: src/test/java/com/hyperwallet/clientsdk/util/HyperwalletJsonUtilTest.java
import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.core.type.TypeReference;
import com.hyperwallet.clientsdk.HyperwalletException;
import com.hyperwallet.clientsdk.model.HyperwalletBaseMonitor;
import org.testng.annotations.Test;
import javax.xml.bind.Element;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
public void clearTest3() {
clearField("test3");
this.test3 = null;
}
}
@JsonFilter(HyperwalletJsonConfiguration.INCLUSION_FILTER)
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public static class TestWithError extends HyperwalletBaseMonitor {
public Element element;
public TestWithError() {
element = new Element() {
};
addField("element", element);
}
}
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testInstanceCreation() {
new HyperwalletJsonUtil();
}
@Test
public void testFromJson_byClassReference_nullContent() {
TestBody body = HyperwalletJsonUtil.fromJson(null, TestBody.class);
assertThat(body, is(nullValue()));
}
|
@Test(expectedExceptions = HyperwalletException.class)
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/model/BaseModelTest.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/util/HyperwalletJsonConfiguration.java
// public class HyperwalletJsonConfiguration {
//
// public static final String INCLUSION_FILTER = "inclusion-filter";
// private ObjectMapper objectMapper;
// private ObjectMapper parsingObjectMapper;
//
// HyperwalletJsonConfiguration() {
// DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
// dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
//
// this.objectMapper = new ObjectMapper()
// .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true)
// .configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
// .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
// .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
// .configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false)
// .configure(SerializationFeature.WRITE_ENUMS_USING_INDEX, false)
// .setDateFormat(dateFormat)
// .setSerializationInclusion(Include.ALWAYS);
//
// this.parsingObjectMapper = new ObjectMapper()
// .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true)
// .configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
// .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
// .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
// .configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false)
// .configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false)
// .configure(SerializationFeature.WRITE_ENUMS_USING_INDEX, false);
// }
//
// public ObjectMapper getParser() {
// return this.parsingObjectMapper;
// }
//
// public ObjectMapper getContext(final Class<?> type) {
// return objectMapper;
// }
//
//
// }
|
import com.fasterxml.jackson.annotation.JsonFilter;
import com.hyperwallet.clientsdk.util.HyperwalletJsonConfiguration;
import org.hamcrest.Matchers;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.testng.Assert.fail;
|
package com.hyperwallet.clientsdk.model;
/**
* @author fkrauthan
*/
public abstract class BaseModelTest<T> {
private T baseModel;
private List<String> fieldNames;
@BeforeMethod
public void setUp() {
this.baseModel = createBaseModel();
this.fieldNames = collectFieldNames();
}
protected abstract T createBaseModel();
protected abstract Class<T> createModelClass();
@Test
public void testJsonFilterAnnotationPresent() throws Exception {
Class<T> clazz = createModelClass();
T model = clazz.newInstance();
if (model instanceof HyperwalletBaseMonitor) {
JsonFilter filter = clazz.getAnnotation(JsonFilter.class);
assertThat(filter, is(notNullValue()));
|
// Path: src/main/java/com/hyperwallet/clientsdk/util/HyperwalletJsonConfiguration.java
// public class HyperwalletJsonConfiguration {
//
// public static final String INCLUSION_FILTER = "inclusion-filter";
// private ObjectMapper objectMapper;
// private ObjectMapper parsingObjectMapper;
//
// HyperwalletJsonConfiguration() {
// DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
// dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
//
// this.objectMapper = new ObjectMapper()
// .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true)
// .configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
// .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
// .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
// .configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false)
// .configure(SerializationFeature.WRITE_ENUMS_USING_INDEX, false)
// .setDateFormat(dateFormat)
// .setSerializationInclusion(Include.ALWAYS);
//
// this.parsingObjectMapper = new ObjectMapper()
// .configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true)
// .configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true)
// .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
// .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
// .configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true)
// .configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false)
// .configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false)
// .configure(SerializationFeature.WRITE_ENUMS_USING_INDEX, false);
// }
//
// public ObjectMapper getParser() {
// return this.parsingObjectMapper;
// }
//
// public ObjectMapper getContext(final Class<?> type) {
// return objectMapper;
// }
//
//
// }
// Path: src/test/java/com/hyperwallet/clientsdk/model/BaseModelTest.java
import com.fasterxml.jackson.annotation.JsonFilter;
import com.hyperwallet.clientsdk.util.HyperwalletJsonConfiguration;
import org.hamcrest.Matchers;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.testng.Assert.fail;
package com.hyperwallet.clientsdk.model;
/**
* @author fkrauthan
*/
public abstract class BaseModelTest<T> {
private T baseModel;
private List<String> fieldNames;
@BeforeMethod
public void setUp() {
this.baseModel = createBaseModel();
this.fieldNames = collectFieldNames();
}
protected abstract T createBaseModel();
protected abstract Class<T> createModelClass();
@Test
public void testJsonFilterAnnotationPresent() throws Exception {
Class<T> clazz = createModelClass();
T model = clazz.newInstance();
if (model instanceof HyperwalletBaseMonitor) {
JsonFilter filter = clazz.getAnnotation(JsonFilter.class);
assertThat(filter, is(notNullValue()));
|
assertThat(filter.value(), is(equalTo(HyperwalletJsonConfiguration.INCLUSION_FILTER)));
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/HyperwalletFT.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/util/Multipart.java
// public class Multipart {
//
// List<MultipartData> multipartList;
//
// public List<MultipartData> getMultipartList() {
// return multipartList;
// }
//
// public void setMultipartList(List<MultipartData> multipartList) {
// this.multipartList = multipartList;
// }
//
// public void add(MultipartData multipartData) {
// if (multipartList == null) {
// multipartList = new ArrayList<MultipartData>();
// }
// multipartList.add(multipartData);
// }
//
// public static class MultipartData {
// private final String contentType; //json, img
// private final Map<String, String> entity; //name, content
// private final String contentDisposition;
//
// MultipartData(String contentType, String contentDisposition, Map<String, String> entity){
// this.contentType = contentType;
// this.contentDisposition = contentDisposition;
// this.entity = entity;
// }
// public String getContentType() {
// return contentType;
// }
//
// public String getContentDisposition() {
// return contentDisposition;
// }
//
// public Map<String, String> getEntity() {
// return entity;
// }
//
// }
// }
|
import com.hyperwallet.clientsdk.model.*;
import com.hyperwallet.clientsdk.util.Multipart;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
|
.firstName("John")
.lastName("Smith")
.postalCode("12345")
.profileType(HyperwalletUser.ProfileType.INDIVIDUAL)
.governmentId("333333333")
.phoneNumber("605-555-1323")
.programToken("invalidToken")
.stateProvince("CA")
.governmentIdType(HyperwalletUser.GovernmentIdType.PASSPORT);
HyperwalletUser returnValue;
try {
client.setHyperwalletProxy("localhost", 3128);
client.setHyperwalletProxyUsername("test1");
client.setHyperwalletProxyPassword("test1");
returnValue = client.createUser(hyperwalletUser);
} catch (Exception e) {
assertThat(e.getMessage(), is(containsString("Proxy Authentication Required")));
}
}
}
@Test
public void testUploadStakeholderDocumentsWithInvalidData() throws Exception {
if (!username.isEmpty()) {
HyperwalletBusinessStakeholder returnValue;
HyperwalletVerificationDocument hyperwalletVerificationDocument = new HyperwalletVerificationDocument();
try {
String userToken = "usr-490848fb-8e1f-4f7c-9a18-a5b7a372e602";
String stkToken = "stk-e08f13b8-0e54-43d2-a587-67d513633275";
|
// Path: src/main/java/com/hyperwallet/clientsdk/util/Multipart.java
// public class Multipart {
//
// List<MultipartData> multipartList;
//
// public List<MultipartData> getMultipartList() {
// return multipartList;
// }
//
// public void setMultipartList(List<MultipartData> multipartList) {
// this.multipartList = multipartList;
// }
//
// public void add(MultipartData multipartData) {
// if (multipartList == null) {
// multipartList = new ArrayList<MultipartData>();
// }
// multipartList.add(multipartData);
// }
//
// public static class MultipartData {
// private final String contentType; //json, img
// private final Map<String, String> entity; //name, content
// private final String contentDisposition;
//
// MultipartData(String contentType, String contentDisposition, Map<String, String> entity){
// this.contentType = contentType;
// this.contentDisposition = contentDisposition;
// this.entity = entity;
// }
// public String getContentType() {
// return contentType;
// }
//
// public String getContentDisposition() {
// return contentDisposition;
// }
//
// public Map<String, String> getEntity() {
// return entity;
// }
//
// }
// }
// Path: src/test/java/com/hyperwallet/clientsdk/HyperwalletFT.java
import com.hyperwallet.clientsdk.model.*;
import com.hyperwallet.clientsdk.util.Multipart;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
.firstName("John")
.lastName("Smith")
.postalCode("12345")
.profileType(HyperwalletUser.ProfileType.INDIVIDUAL)
.governmentId("333333333")
.phoneNumber("605-555-1323")
.programToken("invalidToken")
.stateProvince("CA")
.governmentIdType(HyperwalletUser.GovernmentIdType.PASSPORT);
HyperwalletUser returnValue;
try {
client.setHyperwalletProxy("localhost", 3128);
client.setHyperwalletProxyUsername("test1");
client.setHyperwalletProxyPassword("test1");
returnValue = client.createUser(hyperwalletUser);
} catch (Exception e) {
assertThat(e.getMessage(), is(containsString("Proxy Authentication Required")));
}
}
}
@Test
public void testUploadStakeholderDocumentsWithInvalidData() throws Exception {
if (!username.isEmpty()) {
HyperwalletBusinessStakeholder returnValue;
HyperwalletVerificationDocument hyperwalletVerificationDocument = new HyperwalletVerificationDocument();
try {
String userToken = "usr-490848fb-8e1f-4f7c-9a18-a5b7a372e602";
String stkToken = "stk-e08f13b8-0e54-43d2-a587-67d513633275";
|
Multipart multipart = new Multipart();
|
hyperwallet/java-sdk
|
src/main/java/com/hyperwallet/clientsdk/model/HyperwalletUsersListPaginationOptions.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletUser.java
// public enum TaxVerificationStatus {NOT_REQUIRED, REQUIRED, UNDER_REVIEW, VERIFIED}
|
import com.hyperwallet.clientsdk.model.HyperwalletUser.TaxVerificationStatus;
|
package com.hyperwallet.clientsdk.model;
public class HyperwalletUsersListPaginationOptions extends HyperwalletPaginationOptions{
private String clientUserId;
private String email;
private String programToken;
private HyperwalletUser.Status status;
private HyperwalletUser.VerificationStatus verificationStatus;
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletUser.java
// public enum TaxVerificationStatus {NOT_REQUIRED, REQUIRED, UNDER_REVIEW, VERIFIED}
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletUsersListPaginationOptions.java
import com.hyperwallet.clientsdk.model.HyperwalletUser.TaxVerificationStatus;
package com.hyperwallet.clientsdk.model;
public class HyperwalletUsersListPaginationOptions extends HyperwalletPaginationOptions{
private String clientUserId;
private String email;
private String programToken;
private HyperwalletUser.Status status;
private HyperwalletUser.VerificationStatus verificationStatus;
|
private HyperwalletUser.TaxVerificationStatus taxVerificationStatus;
|
hyperwallet/java-sdk
|
src/main/java/com/hyperwallet/clientsdk/util/HyperwalletApiClient.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletErrorList.java
// @XmlRootElement
// public class HyperwalletErrorList {
//
// public List<HyperwalletError> errors = new ArrayList<HyperwalletError>();
//
// public HyperwalletErrorList() {
// }
//
// public List<HyperwalletError> getErrors() {
// return errors;
// }
//
// public void setErrors(List<HyperwalletError> errors) {
// this.errors = errors;
// }
// }
|
import cc.protea.util.http.Response;
import com.fasterxml.jackson.core.type.TypeReference;
import com.hyperwallet.clientsdk.HyperwalletException;
import com.hyperwallet.clientsdk.model.HyperwalletErrorList;
import com.nimbusds.jose.JOSEException;
import javax.xml.bind.DatatypeConverter;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.text.ParseException;
import java.util.HashMap;
import java.util.UUID;
|
private final String contextId;
private Proxy proxy;
private String proxyUsername;
private String proxyPassword;
public HyperwalletApiClient(final String username, final String password, final String version) {
this(username, password, version, null);
}
public HyperwalletApiClient(final String username, final String password, final String version,
HyperwalletEncryption hyperwalletEncryption) {
this.username = username;
this.password = password;
this.version = version;
this.hyperwalletEncryption = hyperwalletEncryption;
this.isEncrypted = hyperwalletEncryption != null;
this.contextId = String.valueOf(UUID.randomUUID());
// TLS fix
if (System.getProperty("java.version").startsWith("1.7.")) {
System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
}
}
public <T> T get(final String url, final Class<T> type) {
Response response = null;
try {
response = getService(url, true).getResource();
return processResponse(response, type);
} catch (IOException | JOSEException | ParseException e) {
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletErrorList.java
// @XmlRootElement
// public class HyperwalletErrorList {
//
// public List<HyperwalletError> errors = new ArrayList<HyperwalletError>();
//
// public HyperwalletErrorList() {
// }
//
// public List<HyperwalletError> getErrors() {
// return errors;
// }
//
// public void setErrors(List<HyperwalletError> errors) {
// this.errors = errors;
// }
// }
// Path: src/main/java/com/hyperwallet/clientsdk/util/HyperwalletApiClient.java
import cc.protea.util.http.Response;
import com.fasterxml.jackson.core.type.TypeReference;
import com.hyperwallet.clientsdk.HyperwalletException;
import com.hyperwallet.clientsdk.model.HyperwalletErrorList;
import com.nimbusds.jose.JOSEException;
import javax.xml.bind.DatatypeConverter;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.text.ParseException;
import java.util.HashMap;
import java.util.UUID;
private final String contextId;
private Proxy proxy;
private String proxyUsername;
private String proxyPassword;
public HyperwalletApiClient(final String username, final String password, final String version) {
this(username, password, version, null);
}
public HyperwalletApiClient(final String username, final String password, final String version,
HyperwalletEncryption hyperwalletEncryption) {
this.username = username;
this.password = password;
this.version = version;
this.hyperwalletEncryption = hyperwalletEncryption;
this.isEncrypted = hyperwalletEncryption != null;
this.contextId = String.valueOf(UUID.randomUUID());
// TLS fix
if (System.getProperty("java.version").startsWith("1.7.")) {
System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
}
}
public <T> T get(final String url, final Class<T> type) {
Response response = null;
try {
response = getService(url, true).getResource();
return processResponse(response, type);
} catch (IOException | JOSEException | ParseException e) {
|
throw new HyperwalletException(e);
|
hyperwallet/java-sdk
|
src/main/java/com/hyperwallet/clientsdk/util/HyperwalletApiClient.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletErrorList.java
// @XmlRootElement
// public class HyperwalletErrorList {
//
// public List<HyperwalletError> errors = new ArrayList<HyperwalletError>();
//
// public HyperwalletErrorList() {
// }
//
// public List<HyperwalletError> getErrors() {
// return errors;
// }
//
// public void setErrors(List<HyperwalletError> errors) {
// this.errors = errors;
// }
// }
|
import cc.protea.util.http.Response;
import com.fasterxml.jackson.core.type.TypeReference;
import com.hyperwallet.clientsdk.HyperwalletException;
import com.hyperwallet.clientsdk.model.HyperwalletErrorList;
import com.nimbusds.jose.JOSEException;
import javax.xml.bind.DatatypeConverter;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.text.ParseException;
import java.util.HashMap;
import java.util.UUID;
|
response = request.postResource();
return processResponse(response, type);
} catch (IOException | JOSEException | ParseException e) {
throw new HyperwalletException(e);
}
}
protected <T> T processResponse(final Response response, final Class<T> type)
throws ParseException, JOSEException, IOException {
checkErrorResponse(response);
checkResponseHeader(response);
if (response.getResponseCode() == 204) {
return convert("{}", type);
} else {
return convert(decryptResponse(response.getBody()), type);
}
}
protected <T> T processResponse(final Response response, final TypeReference<T> type)
throws ParseException, JOSEException, IOException {
checkErrorResponse(response);
checkResponseHeader(response);
if (response.getResponseCode() == 204) {
return convert("{}", type);
} else {
return convert(decryptResponse(response.getBody()), type);
}
}
protected void checkErrorResponse(final Response response) throws ParseException, JOSEException, IOException {
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletErrorList.java
// @XmlRootElement
// public class HyperwalletErrorList {
//
// public List<HyperwalletError> errors = new ArrayList<HyperwalletError>();
//
// public HyperwalletErrorList() {
// }
//
// public List<HyperwalletError> getErrors() {
// return errors;
// }
//
// public void setErrors(List<HyperwalletError> errors) {
// this.errors = errors;
// }
// }
// Path: src/main/java/com/hyperwallet/clientsdk/util/HyperwalletApiClient.java
import cc.protea.util.http.Response;
import com.fasterxml.jackson.core.type.TypeReference;
import com.hyperwallet.clientsdk.HyperwalletException;
import com.hyperwallet.clientsdk.model.HyperwalletErrorList;
import com.nimbusds.jose.JOSEException;
import javax.xml.bind.DatatypeConverter;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.text.ParseException;
import java.util.HashMap;
import java.util.UUID;
response = request.postResource();
return processResponse(response, type);
} catch (IOException | JOSEException | ParseException e) {
throw new HyperwalletException(e);
}
}
protected <T> T processResponse(final Response response, final Class<T> type)
throws ParseException, JOSEException, IOException {
checkErrorResponse(response);
checkResponseHeader(response);
if (response.getResponseCode() == 204) {
return convert("{}", type);
} else {
return convert(decryptResponse(response.getBody()), type);
}
}
protected <T> T processResponse(final Response response, final TypeReference<T> type)
throws ParseException, JOSEException, IOException {
checkErrorResponse(response);
checkResponseHeader(response);
if (response.getResponseCode() == 204) {
return convert("{}", type);
} else {
return convert(decryptResponse(response.getBody()), type);
}
}
protected void checkErrorResponse(final Response response) throws ParseException, JOSEException, IOException {
|
HyperwalletErrorList errorList = null;
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/model/HyperwalletUsersListPaginationOptionsTest.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletUser.java
// public enum TaxVerificationStatus {NOT_REQUIRED, REQUIRED, UNDER_REVIEW, VERIFIED}
|
import com.hyperwallet.clientsdk.model.HyperwalletUser.TaxVerificationStatus;
|
package com.hyperwallet.clientsdk.model;
public class HyperwalletUsersListPaginationOptionsTest extends BaseModelTest<HyperwalletUsersListPaginationOptions> {
@Override
protected HyperwalletUsersListPaginationOptions createBaseModel() {
HyperwalletUsersListPaginationOptions options = new HyperwalletUsersListPaginationOptions();
options
.clientUserId("test-client-id")
.email("[email protected]")
.programToken("test-prg-token")
.status(HyperwalletUser.Status.ACTIVATED)
.verificationStatus(HyperwalletUser.VerificationStatus.REQUIRED)
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletUser.java
// public enum TaxVerificationStatus {NOT_REQUIRED, REQUIRED, UNDER_REVIEW, VERIFIED}
// Path: src/test/java/com/hyperwallet/clientsdk/model/HyperwalletUsersListPaginationOptionsTest.java
import com.hyperwallet.clientsdk.model.HyperwalletUser.TaxVerificationStatus;
package com.hyperwallet.clientsdk.model;
public class HyperwalletUsersListPaginationOptionsTest extends BaseModelTest<HyperwalletUsersListPaginationOptions> {
@Override
protected HyperwalletUsersListPaginationOptions createBaseModel() {
HyperwalletUsersListPaginationOptions options = new HyperwalletUsersListPaginationOptions();
options
.clientUserId("test-client-id")
.email("[email protected]")
.programToken("test-prg-token")
.status(HyperwalletUser.Status.ACTIVATED)
.verificationStatus(HyperwalletUser.VerificationStatus.REQUIRED)
|
.taxVerificationStatus(TaxVerificationStatus.REQUIRED);
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/model/HyperwalletPrepaidCardTest.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletPrepaidCard.java
// public enum EReplacePrepaidCardReason {LOST_STOLEN, DAMAGED, COMPROMISED, EXPIRED, VIRTUAL_TO_PHYSICAL}
|
import com.hyperwallet.clientsdk.model.HyperwalletPrepaidCard.EReplacePrepaidCardReason;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
|
package com.hyperwallet.clientsdk.model;
/**
* @author fkrauthan
*/
public class HyperwalletPrepaidCardTest extends BaseModelTest<HyperwalletPrepaidCard> {
protected HyperwalletPrepaidCard createBaseModel() {
HyperwalletPrepaidCard prepaidCard = new HyperwalletPrepaidCard();
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
prepaidCard
.token("test-token")
.type(HyperwalletPrepaidCard.Type.PREPAID_CARD)
.status(HyperwalletPrepaidCard.Status.ACTIVATED)
.createdOn(new Date())
.transferMethodCountry("test-transfer-method-country")
.transferMethodCurrency("test-transfer-method-currency")
.cardType(HyperwalletPrepaidCard.CardType.VIRTUAL)
.cardPackage("test-card-package")
.cardNumber("test-card-number")
.cardBrand(HyperwalletPrepaidCard.Brand.VISA)
.dateOfExpiry(new Date())
.userToken("test-user-token")
.replacementOf("replacementOf")
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletPrepaidCard.java
// public enum EReplacePrepaidCardReason {LOST_STOLEN, DAMAGED, COMPROMISED, EXPIRED, VIRTUAL_TO_PHYSICAL}
// Path: src/test/java/com/hyperwallet/clientsdk/model/HyperwalletPrepaidCardTest.java
import com.hyperwallet.clientsdk.model.HyperwalletPrepaidCard.EReplacePrepaidCardReason;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
package com.hyperwallet.clientsdk.model;
/**
* @author fkrauthan
*/
public class HyperwalletPrepaidCardTest extends BaseModelTest<HyperwalletPrepaidCard> {
protected HyperwalletPrepaidCard createBaseModel() {
HyperwalletPrepaidCard prepaidCard = new HyperwalletPrepaidCard();
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
prepaidCard
.token("test-token")
.type(HyperwalletPrepaidCard.Type.PREPAID_CARD)
.status(HyperwalletPrepaidCard.Status.ACTIVATED)
.createdOn(new Date())
.transferMethodCountry("test-transfer-method-country")
.transferMethodCurrency("test-transfer-method-currency")
.cardType(HyperwalletPrepaidCard.CardType.VIRTUAL)
.cardPackage("test-card-package")
.cardNumber("test-card-number")
.cardBrand(HyperwalletPrepaidCard.Brand.VISA)
.dateOfExpiry(new Date())
.userToken("test-user-token")
.replacementOf("replacementOf")
|
.replacementReason(EReplacePrepaidCardReason.DAMAGED)
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/model/HyperwalletTransferRefundTest.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransfer.java
// public static class ForeignExchange {
//
// private Double sourceAmount;
// private String sourceCurrency;
// private Double destinationAmount;
// private String destinationCurrency;
// private Double rate;
//
// public Double getSourceAmount() {
// return sourceAmount;
// }
//
// public void setSourceAmount(Double sourceAmount) {
// this.sourceAmount = sourceAmount;
// }
//
// public String getSourceCurrency() {
// return sourceCurrency;
// }
//
// public void setSourceCurrency(String sourceCurrency) {
// this.sourceCurrency = sourceCurrency;
// }
//
// public Double getDestinationAmount() {
// return destinationAmount;
// }
//
// public void setDestinationAmount(Double destinationAmount) {
// this.destinationAmount = destinationAmount;
// }
//
// public String getDestinationCurrency() {
// return destinationCurrency;
// }
//
// public void setDestinationCurrency(String destinationCurrency) {
// this.destinationCurrency = destinationCurrency;
// }
//
// public Double getRate() {
// return rate;
// }
//
// public void setRate(Double rate) {
// this.rate = rate;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferRefund.java
// public static enum Status {PENDING, FAILED, COMPLETED}
|
import com.hyperwallet.clientsdk.model.HyperwalletTransfer.ForeignExchange;
import com.hyperwallet.clientsdk.model.HyperwalletTransferRefund.Status;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
|
package com.hyperwallet.clientsdk.model;
public class HyperwalletTransferRefundTest extends BaseModelTest<HyperwalletTransferRefund> {
@Override
protected HyperwalletTransferRefund createBaseModel() {
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransfer.java
// public static class ForeignExchange {
//
// private Double sourceAmount;
// private String sourceCurrency;
// private Double destinationAmount;
// private String destinationCurrency;
// private Double rate;
//
// public Double getSourceAmount() {
// return sourceAmount;
// }
//
// public void setSourceAmount(Double sourceAmount) {
// this.sourceAmount = sourceAmount;
// }
//
// public String getSourceCurrency() {
// return sourceCurrency;
// }
//
// public void setSourceCurrency(String sourceCurrency) {
// this.sourceCurrency = sourceCurrency;
// }
//
// public Double getDestinationAmount() {
// return destinationAmount;
// }
//
// public void setDestinationAmount(Double destinationAmount) {
// this.destinationAmount = destinationAmount;
// }
//
// public String getDestinationCurrency() {
// return destinationCurrency;
// }
//
// public void setDestinationCurrency(String destinationCurrency) {
// this.destinationCurrency = destinationCurrency;
// }
//
// public Double getRate() {
// return rate;
// }
//
// public void setRate(Double rate) {
// this.rate = rate;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferRefund.java
// public static enum Status {PENDING, FAILED, COMPLETED}
// Path: src/test/java/com/hyperwallet/clientsdk/model/HyperwalletTransferRefundTest.java
import com.hyperwallet.clientsdk.model.HyperwalletTransfer.ForeignExchange;
import com.hyperwallet.clientsdk.model.HyperwalletTransferRefund.Status;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
package com.hyperwallet.clientsdk.model;
public class HyperwalletTransferRefundTest extends BaseModelTest<HyperwalletTransferRefund> {
@Override
protected HyperwalletTransferRefund createBaseModel() {
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
|
ForeignExchange foreignExchange = new ForeignExchange();
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/model/HyperwalletTransferRefundTest.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransfer.java
// public static class ForeignExchange {
//
// private Double sourceAmount;
// private String sourceCurrency;
// private Double destinationAmount;
// private String destinationCurrency;
// private Double rate;
//
// public Double getSourceAmount() {
// return sourceAmount;
// }
//
// public void setSourceAmount(Double sourceAmount) {
// this.sourceAmount = sourceAmount;
// }
//
// public String getSourceCurrency() {
// return sourceCurrency;
// }
//
// public void setSourceCurrency(String sourceCurrency) {
// this.sourceCurrency = sourceCurrency;
// }
//
// public Double getDestinationAmount() {
// return destinationAmount;
// }
//
// public void setDestinationAmount(Double destinationAmount) {
// this.destinationAmount = destinationAmount;
// }
//
// public String getDestinationCurrency() {
// return destinationCurrency;
// }
//
// public void setDestinationCurrency(String destinationCurrency) {
// this.destinationCurrency = destinationCurrency;
// }
//
// public Double getRate() {
// return rate;
// }
//
// public void setRate(Double rate) {
// this.rate = rate;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferRefund.java
// public static enum Status {PENDING, FAILED, COMPLETED}
|
import com.hyperwallet.clientsdk.model.HyperwalletTransfer.ForeignExchange;
import com.hyperwallet.clientsdk.model.HyperwalletTransferRefund.Status;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
|
package com.hyperwallet.clientsdk.model;
public class HyperwalletTransferRefundTest extends BaseModelTest<HyperwalletTransferRefund> {
@Override
protected HyperwalletTransferRefund createBaseModel() {
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
ForeignExchange foreignExchange = new ForeignExchange();
foreignExchange.setSourceAmount(200.0);
foreignExchange.setSourceCurrency("USD");
foreignExchange.setDestinationAmount(100.0);
foreignExchange.setDestinationCurrency("CAD");
foreignExchange.setRate(2.3);
HyperwalletTransferRefund transferRefund = new HyperwalletTransferRefund()
.token("token")
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransfer.java
// public static class ForeignExchange {
//
// private Double sourceAmount;
// private String sourceCurrency;
// private Double destinationAmount;
// private String destinationCurrency;
// private Double rate;
//
// public Double getSourceAmount() {
// return sourceAmount;
// }
//
// public void setSourceAmount(Double sourceAmount) {
// this.sourceAmount = sourceAmount;
// }
//
// public String getSourceCurrency() {
// return sourceCurrency;
// }
//
// public void setSourceCurrency(String sourceCurrency) {
// this.sourceCurrency = sourceCurrency;
// }
//
// public Double getDestinationAmount() {
// return destinationAmount;
// }
//
// public void setDestinationAmount(Double destinationAmount) {
// this.destinationAmount = destinationAmount;
// }
//
// public String getDestinationCurrency() {
// return destinationCurrency;
// }
//
// public void setDestinationCurrency(String destinationCurrency) {
// this.destinationCurrency = destinationCurrency;
// }
//
// public Double getRate() {
// return rate;
// }
//
// public void setRate(Double rate) {
// this.rate = rate;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferRefund.java
// public static enum Status {PENDING, FAILED, COMPLETED}
// Path: src/test/java/com/hyperwallet/clientsdk/model/HyperwalletTransferRefundTest.java
import com.hyperwallet.clientsdk.model.HyperwalletTransfer.ForeignExchange;
import com.hyperwallet.clientsdk.model.HyperwalletTransferRefund.Status;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
package com.hyperwallet.clientsdk.model;
public class HyperwalletTransferRefundTest extends BaseModelTest<HyperwalletTransferRefund> {
@Override
protected HyperwalletTransferRefund createBaseModel() {
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
ForeignExchange foreignExchange = new ForeignExchange();
foreignExchange.setSourceAmount(200.0);
foreignExchange.setSourceCurrency("USD");
foreignExchange.setDestinationAmount(100.0);
foreignExchange.setDestinationCurrency("CAD");
foreignExchange.setRate(2.3);
HyperwalletTransferRefund transferRefund = new HyperwalletTransferRefund()
.token("token")
|
.status(Status.COMPLETED)
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/util/HyperwalletEncryptionTest.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
|
import com.hyperwallet.clientsdk.HyperwalletException;
import com.nimbusds.jose.EncryptionMethod;
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JWEAlgorithm;
import com.nimbusds.jose.JWSAlgorithm;
import org.apache.commons.io.IOUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.URISyntaxException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.testng.Assert.fail;
|
public void shouldThrowExceptionWhenKeySetFileIsNotFound()
throws URISyntaxException, IOException, ParseException, JOSEException {
ClassLoader classLoader = getClass().getClassLoader();
String hyperwalletKeysPath = new File(classLoader.getResource("encryption/public-jwkset").toURI()).getAbsolutePath();
String clientPrivateKeysPath = "/encryption/public-jwkset/keyset.json";
String testPayload = IOUtils.toString(classLoader.getResourceAsStream("encryption/test-payload.json"));
HyperwalletEncryption hyperwalletEncryption = new HyperwalletEncryption.HyperwalletEncryptionBuilder()
.clientPrivateKeySetLocation(clientPrivateKeysPath).hyperwalletKeySetLocation(hyperwalletKeysPath).build();
try {
hyperwalletEncryption.encrypt(testPayload);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), is(containsString("Wrong client JWK set location")));
}
}
@Test
public void shouldThrowExceptionWhenJWSSignatureExpirationDateIsNull() throws URISyntaxException {
ClassLoader classLoader = getClass().getClassLoader();
String hyperwalletKeysPath = new File(classLoader.getResource("encryption/public-jwkset").toURI()).getAbsolutePath();
String clientPrivateKeysPath = new File(classLoader.getResource("encryption/private-jwkset").toURI()).getAbsolutePath();
HyperwalletEncryption hyperwalletEncryption = new HyperwalletEncryption.HyperwalletEncryptionBuilder()
.clientPrivateKeySetLocation(clientPrivateKeysPath).hyperwalletKeySetLocation(hyperwalletKeysPath).build();
try {
hyperwalletEncryption.verifySignatureExpirationDate(null);
fail("Expected HyperwalletException");
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
// Path: src/test/java/com/hyperwallet/clientsdk/util/HyperwalletEncryptionTest.java
import com.hyperwallet.clientsdk.HyperwalletException;
import com.nimbusds.jose.EncryptionMethod;
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JWEAlgorithm;
import com.nimbusds.jose.JWSAlgorithm;
import org.apache.commons.io.IOUtils;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.net.URISyntaxException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.testng.Assert.fail;
public void shouldThrowExceptionWhenKeySetFileIsNotFound()
throws URISyntaxException, IOException, ParseException, JOSEException {
ClassLoader classLoader = getClass().getClassLoader();
String hyperwalletKeysPath = new File(classLoader.getResource("encryption/public-jwkset").toURI()).getAbsolutePath();
String clientPrivateKeysPath = "/encryption/public-jwkset/keyset.json";
String testPayload = IOUtils.toString(classLoader.getResourceAsStream("encryption/test-payload.json"));
HyperwalletEncryption hyperwalletEncryption = new HyperwalletEncryption.HyperwalletEncryptionBuilder()
.clientPrivateKeySetLocation(clientPrivateKeysPath).hyperwalletKeySetLocation(hyperwalletKeysPath).build();
try {
hyperwalletEncryption.encrypt(testPayload);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertThat(e.getMessage(), is(containsString("Wrong client JWK set location")));
}
}
@Test
public void shouldThrowExceptionWhenJWSSignatureExpirationDateIsNull() throws URISyntaxException {
ClassLoader classLoader = getClass().getClassLoader();
String hyperwalletKeysPath = new File(classLoader.getResource("encryption/public-jwkset").toURI()).getAbsolutePath();
String clientPrivateKeysPath = new File(classLoader.getResource("encryption/private-jwkset").toURI()).getAbsolutePath();
HyperwalletEncryption hyperwalletEncryption = new HyperwalletEncryption.HyperwalletEncryptionBuilder()
.clientPrivateKeySetLocation(clientPrivateKeysPath).hyperwalletKeySetLocation(hyperwalletKeysPath).build();
try {
hyperwalletEncryption.verifySignatureExpirationDate(null);
fail("Expected HyperwalletException");
|
} catch (HyperwalletException e) {
|
hyperwallet/java-sdk
|
src/main/java/com/hyperwallet/clientsdk/util/HyperwalletJsonUtil.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBaseMonitor.java
// public class HyperwalletBaseMonitor {
//
// @JsonIgnore
// private Set<String> inclusions = new HashSet<String>();
//
// protected HyperwalletBaseMonitor() {
// }
//
// public Set<String> getInclusions() {
// return inclusions;
// }
//
// protected void addField(String field, Object o) {
// if (o == null && inclusions.contains(field)) {
// inclusions.remove(field);
// } else if (o != null) {
// inclusions.add(field);
// }
// }
//
// protected void clearField(String field) {
// inclusions.add(field);
// }
// }
|
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import com.hyperwallet.clientsdk.HyperwalletException;
import com.hyperwallet.clientsdk.model.HyperwalletBaseMonitor;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
|
package com.hyperwallet.clientsdk.util;
public class HyperwalletJsonUtil {
private static ObjectMapper objectMapper = new HyperwalletJsonConfiguration().getContext(Void.class);
private static ObjectMapper parser = new HyperwalletJsonConfiguration().getParser();
public HyperwalletJsonUtil() {
throw new UnsupportedOperationException("This is a util class!");
}
public static <T> T fromJson(final String content, final Class<T> valueType) {
if (StringUtils.isBlank(content)) {
return null;
}
try {
return HyperwalletJsonUtil.parser.readValue(content, valueType);
} catch (IOException e) {
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBaseMonitor.java
// public class HyperwalletBaseMonitor {
//
// @JsonIgnore
// private Set<String> inclusions = new HashSet<String>();
//
// protected HyperwalletBaseMonitor() {
// }
//
// public Set<String> getInclusions() {
// return inclusions;
// }
//
// protected void addField(String field, Object o) {
// if (o == null && inclusions.contains(field)) {
// inclusions.remove(field);
// } else if (o != null) {
// inclusions.add(field);
// }
// }
//
// protected void clearField(String field) {
// inclusions.add(field);
// }
// }
// Path: src/main/java/com/hyperwallet/clientsdk/util/HyperwalletJsonUtil.java
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import com.hyperwallet.clientsdk.HyperwalletException;
import com.hyperwallet.clientsdk.model.HyperwalletBaseMonitor;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
package com.hyperwallet.clientsdk.util;
public class HyperwalletJsonUtil {
private static ObjectMapper objectMapper = new HyperwalletJsonConfiguration().getContext(Void.class);
private static ObjectMapper parser = new HyperwalletJsonConfiguration().getParser();
public HyperwalletJsonUtil() {
throw new UnsupportedOperationException("This is a util class!");
}
public static <T> T fromJson(final String content, final Class<T> valueType) {
if (StringUtils.isBlank(content)) {
return null;
}
try {
return HyperwalletJsonUtil.parser.readValue(content, valueType);
} catch (IOException e) {
|
throw new HyperwalletException(e);
|
hyperwallet/java-sdk
|
src/main/java/com/hyperwallet/clientsdk/util/HyperwalletJsonUtil.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBaseMonitor.java
// public class HyperwalletBaseMonitor {
//
// @JsonIgnore
// private Set<String> inclusions = new HashSet<String>();
//
// protected HyperwalletBaseMonitor() {
// }
//
// public Set<String> getInclusions() {
// return inclusions;
// }
//
// protected void addField(String field, Object o) {
// if (o == null && inclusions.contains(field)) {
// inclusions.remove(field);
// } else if (o != null) {
// inclusions.add(field);
// }
// }
//
// protected void clearField(String field) {
// inclusions.add(field);
// }
// }
|
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import com.hyperwallet.clientsdk.HyperwalletException;
import com.hyperwallet.clientsdk.model.HyperwalletBaseMonitor;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
|
throw new UnsupportedOperationException("This is a util class!");
}
public static <T> T fromJson(final String content, final Class<T> valueType) {
if (StringUtils.isBlank(content)) {
return null;
}
try {
return HyperwalletJsonUtil.parser.readValue(content, valueType);
} catch (IOException e) {
throw new HyperwalletException(e);
}
}
public static <T> T fromJson(final String content, final TypeReference<T> valueType) {
if (StringUtils.isBlank(content)) {
return null;
}
try {
return HyperwalletJsonUtil.parser.readValue(content, valueType);
} catch (IOException e) {
throw new HyperwalletException(e);
}
}
public static String toJson(final Object object) {
if (object == null) {
return null;
}
try {
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBaseMonitor.java
// public class HyperwalletBaseMonitor {
//
// @JsonIgnore
// private Set<String> inclusions = new HashSet<String>();
//
// protected HyperwalletBaseMonitor() {
// }
//
// public Set<String> getInclusions() {
// return inclusions;
// }
//
// protected void addField(String field, Object o) {
// if (o == null && inclusions.contains(field)) {
// inclusions.remove(field);
// } else if (o != null) {
// inclusions.add(field);
// }
// }
//
// protected void clearField(String field) {
// inclusions.add(field);
// }
// }
// Path: src/main/java/com/hyperwallet/clientsdk/util/HyperwalletJsonUtil.java
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import com.hyperwallet.clientsdk.HyperwalletException;
import com.hyperwallet.clientsdk.model.HyperwalletBaseMonitor;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
throw new UnsupportedOperationException("This is a util class!");
}
public static <T> T fromJson(final String content, final Class<T> valueType) {
if (StringUtils.isBlank(content)) {
return null;
}
try {
return HyperwalletJsonUtil.parser.readValue(content, valueType);
} catch (IOException e) {
throw new HyperwalletException(e);
}
}
public static <T> T fromJson(final String content, final TypeReference<T> valueType) {
if (StringUtils.isBlank(content)) {
return null;
}
try {
return HyperwalletJsonUtil.parser.readValue(content, valueType);
} catch (IOException e) {
throw new HyperwalletException(e);
}
}
public static String toJson(final Object object) {
if (object == null) {
return null;
}
try {
|
HyperwalletBaseMonitor base = (HyperwalletBaseMonitor) object;
|
hyperwallet/java-sdk
|
src/main/java/com/hyperwallet/clientsdk/model/HyperwalletVenmoAccountListPaginationOptions.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletVenmoAccount.java
// public enum Status {ACTIVATED, INVALID, VERIFIED, DE_ACTIVATED}
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletVenmoAccount.java
// public enum Type {VENMO_ACCOUNT}
|
import com.hyperwallet.clientsdk.model.HyperwalletVenmoAccount.Status;
import com.hyperwallet.clientsdk.model.HyperwalletVenmoAccount.Type;
|
package com.hyperwallet.clientsdk.model;
public class HyperwalletVenmoAccountListPaginationOptions extends HyperwalletPaginationOptions {
private HyperwalletVenmoAccount.Status status;
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletVenmoAccount.java
// public enum Status {ACTIVATED, INVALID, VERIFIED, DE_ACTIVATED}
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletVenmoAccount.java
// public enum Type {VENMO_ACCOUNT}
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletVenmoAccountListPaginationOptions.java
import com.hyperwallet.clientsdk.model.HyperwalletVenmoAccount.Status;
import com.hyperwallet.clientsdk.model.HyperwalletVenmoAccount.Type;
package com.hyperwallet.clientsdk.model;
public class HyperwalletVenmoAccountListPaginationOptions extends HyperwalletPaginationOptions {
private HyperwalletVenmoAccount.Status status;
|
private HyperwalletVenmoAccount.Type type;
|
hyperwallet/java-sdk
|
src/main/java/com/hyperwallet/clientsdk/util/HyperwalletEncryption.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
|
import com.hyperwallet.clientsdk.HyperwalletException;
import com.nimbusds.jose.Algorithm;
import com.nimbusds.jose.EncryptionMethod;
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JWEAlgorithm;
import com.nimbusds.jose.JWEDecrypter;
import com.nimbusds.jose.JWEEncrypter;
import com.nimbusds.jose.JWEHeader;
import com.nimbusds.jose.JWEObject;
import com.nimbusds.jose.JWSAlgorithm;
import com.nimbusds.jose.JWSHeader;
import com.nimbusds.jose.JWSObject;
import com.nimbusds.jose.JWSSigner;
import com.nimbusds.jose.JWSVerifier;
import com.nimbusds.jose.Payload;
import com.nimbusds.jose.crypto.ECDHDecrypter;
import com.nimbusds.jose.crypto.ECDHEncrypter;
import com.nimbusds.jose.crypto.ECDSASigner;
import com.nimbusds.jose.crypto.ECDSAVerifier;
import com.nimbusds.jose.crypto.RSADecrypter;
import com.nimbusds.jose.crypto.RSAEncrypter;
import com.nimbusds.jose.crypto.RSASSASigner;
import com.nimbusds.jose.crypto.RSASSAVerifier;
import com.nimbusds.jose.jwk.ECKey;
import com.nimbusds.jose.jwk.JWK;
import com.nimbusds.jose.jwk.JWKSet;
import com.nimbusds.jose.jwk.KeyType;
import com.nimbusds.jose.jwk.RSAKey;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
|
.keyID(clientPrivateKey.getKeyID())
.criticalParams(new HashSet<>(Collections.singletonList(EXPIRATION)))
.customParam(EXPIRATION, getJWSExpirationMillis()).build(),
new Payload(body));
jwsObject.sign(jwsSigner);
JWEObject jweObject = new JWEObject(
new JWEHeader.Builder(encryptionAlgorithm, encryptionMethod)
.keyID(hyperwalletPublicKey.getKeyID()).build(),
new Payload(jwsObject));
jweObject.encrypt(jweEncrypter);
return jweObject.serialize();
}
public String decrypt(String body) throws ParseException, IOException, JOSEException {
JWK privateKeyToDecrypt = getKeyByAlgorithm(loadKeySet(clientPrivateKeySetLocation), encryptionAlgorithm);
JWK publicKeyToSign = getKeyByAlgorithm(loadKeySet(hyperwalletKeySetLocation), signAlgorithm);
JWEDecrypter jweDecrypter = getJWEDecrypter(privateKeyToDecrypt);
JWSVerifier jwsVerifier = getJWSVerifier(publicKeyToSign);
JWEObject jweObject = JWEObject.parse(body);
jweObject.decrypt(jweDecrypter);
JWSObject jwsObject = jweObject.getPayload().toJWSObject();
verifySignatureExpirationDate(jwsObject.getHeader().getCustomParam(EXPIRATION));
boolean verifyStatus = jwsObject.verify(jwsVerifier);
if (!verifyStatus) {
|
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
// public class HyperwalletException extends RuntimeException {
//
// private static final long serialVersionUID = 1L;
//
// private Response response = null;
// private String errorMessage;
// private String errorCode;
// private List<String> relatedResources;
// private HyperwalletErrorList hyperwalletErrorList;
//
// public HyperwalletException(final Exception e) {
// super(e);
// }
//
// public HyperwalletException(final Response response, final int code, final String message) {
// super(message);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
// super(e);
//
// this.response = response;
// errorCode = Integer.toString(code);
// errorMessage = message;
// }
//
// public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
// super(hyperwalletErrorList.getErrors().get(0).getMessage());
//
// this.response = response;
// this.hyperwalletErrorList = hyperwalletErrorList;
// HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
// errorCode = error.getCode();
// errorMessage = error.getMessage();
// relatedResources = error.getRelatedResources();
// }
//
// public HyperwalletException(final String errorMessage) {
// super(errorMessage);
//
// this.errorMessage = errorMessage;
// }
//
// public Response getResponse() {
// return response;
// }
//
// public String getErrorMessage() {
// return errorMessage;
// }
//
// public String getErrorCode() {
// return errorCode;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
//
// public List<HyperwalletError> getHyperwalletErrors() {
// return hyperwalletErrorList != null ? hyperwalletErrorList.getErrors() : null;
// }
// }
// Path: src/main/java/com/hyperwallet/clientsdk/util/HyperwalletEncryption.java
import com.hyperwallet.clientsdk.HyperwalletException;
import com.nimbusds.jose.Algorithm;
import com.nimbusds.jose.EncryptionMethod;
import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JWEAlgorithm;
import com.nimbusds.jose.JWEDecrypter;
import com.nimbusds.jose.JWEEncrypter;
import com.nimbusds.jose.JWEHeader;
import com.nimbusds.jose.JWEObject;
import com.nimbusds.jose.JWSAlgorithm;
import com.nimbusds.jose.JWSHeader;
import com.nimbusds.jose.JWSObject;
import com.nimbusds.jose.JWSSigner;
import com.nimbusds.jose.JWSVerifier;
import com.nimbusds.jose.Payload;
import com.nimbusds.jose.crypto.ECDHDecrypter;
import com.nimbusds.jose.crypto.ECDHEncrypter;
import com.nimbusds.jose.crypto.ECDSASigner;
import com.nimbusds.jose.crypto.ECDSAVerifier;
import com.nimbusds.jose.crypto.RSADecrypter;
import com.nimbusds.jose.crypto.RSAEncrypter;
import com.nimbusds.jose.crypto.RSASSASigner;
import com.nimbusds.jose.crypto.RSASSAVerifier;
import com.nimbusds.jose.jwk.ECKey;
import com.nimbusds.jose.jwk.JWK;
import com.nimbusds.jose.jwk.JWKSet;
import com.nimbusds.jose.jwk.KeyType;
import com.nimbusds.jose.jwk.RSAKey;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.text.ParseException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
.keyID(clientPrivateKey.getKeyID())
.criticalParams(new HashSet<>(Collections.singletonList(EXPIRATION)))
.customParam(EXPIRATION, getJWSExpirationMillis()).build(),
new Payload(body));
jwsObject.sign(jwsSigner);
JWEObject jweObject = new JWEObject(
new JWEHeader.Builder(encryptionAlgorithm, encryptionMethod)
.keyID(hyperwalletPublicKey.getKeyID()).build(),
new Payload(jwsObject));
jweObject.encrypt(jweEncrypter);
return jweObject.serialize();
}
public String decrypt(String body) throws ParseException, IOException, JOSEException {
JWK privateKeyToDecrypt = getKeyByAlgorithm(loadKeySet(clientPrivateKeySetLocation), encryptionAlgorithm);
JWK publicKeyToSign = getKeyByAlgorithm(loadKeySet(hyperwalletKeySetLocation), signAlgorithm);
JWEDecrypter jweDecrypter = getJWEDecrypter(privateKeyToDecrypt);
JWSVerifier jwsVerifier = getJWSVerifier(publicKeyToSign);
JWEObject jweObject = JWEObject.parse(body);
jweObject.decrypt(jweDecrypter);
JWSObject jwsObject = jweObject.getPayload().toJWSObject();
verifySignatureExpirationDate(jwsObject.getHeader().getCustomParam(EXPIRATION));
boolean verifyStatus = jwsObject.verify(jwsVerifier);
if (!verifyStatus) {
|
throw new HyperwalletException("JWS signature is incorrect");
|
hyperwallet/java-sdk
|
src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletError.java
// @XmlRootElement
// public class HyperwalletError {
//
// private String code;
// private String fieldName;
// private String message;
// private List<String> relatedResources;
//
// public HyperwalletError() {
// }
//
// public HyperwalletError(String code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public HyperwalletError(String code, String fieldName, String message) {
// this.code = code;
// this.fieldName = fieldName;
// this.message = message;
// }
//
// public HyperwalletError(String code, String fieldName, String message, List<String> relatedResources) {
// this.code = code;
// this.fieldName = fieldName;
// this.message = message;
// this.relatedResources = relatedResources;
// }
//
// public String getCode() {
// return code;
// }
//
// public String getFieldName() {
// return fieldName;
// }
//
// public String getMessage() {
// return message;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletErrorList.java
// @XmlRootElement
// public class HyperwalletErrorList {
//
// public List<HyperwalletError> errors = new ArrayList<HyperwalletError>();
//
// public HyperwalletErrorList() {
// }
//
// public List<HyperwalletError> getErrors() {
// return errors;
// }
//
// public void setErrors(List<HyperwalletError> errors) {
// this.errors = errors;
// }
// }
|
import cc.protea.util.http.Response;
import com.hyperwallet.clientsdk.model.HyperwalletError;
import com.hyperwallet.clientsdk.model.HyperwalletErrorList;
import java.util.List;
|
package com.hyperwallet.clientsdk;
public class HyperwalletException extends RuntimeException {
private static final long serialVersionUID = 1L;
private Response response = null;
private String errorMessage;
private String errorCode;
private List<String> relatedResources;
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletError.java
// @XmlRootElement
// public class HyperwalletError {
//
// private String code;
// private String fieldName;
// private String message;
// private List<String> relatedResources;
//
// public HyperwalletError() {
// }
//
// public HyperwalletError(String code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public HyperwalletError(String code, String fieldName, String message) {
// this.code = code;
// this.fieldName = fieldName;
// this.message = message;
// }
//
// public HyperwalletError(String code, String fieldName, String message, List<String> relatedResources) {
// this.code = code;
// this.fieldName = fieldName;
// this.message = message;
// this.relatedResources = relatedResources;
// }
//
// public String getCode() {
// return code;
// }
//
// public String getFieldName() {
// return fieldName;
// }
//
// public String getMessage() {
// return message;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletErrorList.java
// @XmlRootElement
// public class HyperwalletErrorList {
//
// public List<HyperwalletError> errors = new ArrayList<HyperwalletError>();
//
// public HyperwalletErrorList() {
// }
//
// public List<HyperwalletError> getErrors() {
// return errors;
// }
//
// public void setErrors(List<HyperwalletError> errors) {
// this.errors = errors;
// }
// }
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
import cc.protea.util.http.Response;
import com.hyperwallet.clientsdk.model.HyperwalletError;
import com.hyperwallet.clientsdk.model.HyperwalletErrorList;
import java.util.List;
package com.hyperwallet.clientsdk;
public class HyperwalletException extends RuntimeException {
private static final long serialVersionUID = 1L;
private Response response = null;
private String errorMessage;
private String errorCode;
private List<String> relatedResources;
|
private HyperwalletErrorList hyperwalletErrorList;
|
hyperwallet/java-sdk
|
src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletError.java
// @XmlRootElement
// public class HyperwalletError {
//
// private String code;
// private String fieldName;
// private String message;
// private List<String> relatedResources;
//
// public HyperwalletError() {
// }
//
// public HyperwalletError(String code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public HyperwalletError(String code, String fieldName, String message) {
// this.code = code;
// this.fieldName = fieldName;
// this.message = message;
// }
//
// public HyperwalletError(String code, String fieldName, String message, List<String> relatedResources) {
// this.code = code;
// this.fieldName = fieldName;
// this.message = message;
// this.relatedResources = relatedResources;
// }
//
// public String getCode() {
// return code;
// }
//
// public String getFieldName() {
// return fieldName;
// }
//
// public String getMessage() {
// return message;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletErrorList.java
// @XmlRootElement
// public class HyperwalletErrorList {
//
// public List<HyperwalletError> errors = new ArrayList<HyperwalletError>();
//
// public HyperwalletErrorList() {
// }
//
// public List<HyperwalletError> getErrors() {
// return errors;
// }
//
// public void setErrors(List<HyperwalletError> errors) {
// this.errors = errors;
// }
// }
|
import cc.protea.util.http.Response;
import com.hyperwallet.clientsdk.model.HyperwalletError;
import com.hyperwallet.clientsdk.model.HyperwalletErrorList;
import java.util.List;
|
package com.hyperwallet.clientsdk;
public class HyperwalletException extends RuntimeException {
private static final long serialVersionUID = 1L;
private Response response = null;
private String errorMessage;
private String errorCode;
private List<String> relatedResources;
private HyperwalletErrorList hyperwalletErrorList;
public HyperwalletException(final Exception e) {
super(e);
}
public HyperwalletException(final Response response, final int code, final String message) {
super(message);
this.response = response;
errorCode = Integer.toString(code);
errorMessage = message;
}
public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
super(e);
this.response = response;
errorCode = Integer.toString(code);
errorMessage = message;
}
public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
super(hyperwalletErrorList.getErrors().get(0).getMessage());
this.response = response;
this.hyperwalletErrorList = hyperwalletErrorList;
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletError.java
// @XmlRootElement
// public class HyperwalletError {
//
// private String code;
// private String fieldName;
// private String message;
// private List<String> relatedResources;
//
// public HyperwalletError() {
// }
//
// public HyperwalletError(String code, String message) {
// this.code = code;
// this.message = message;
// }
//
// public HyperwalletError(String code, String fieldName, String message) {
// this.code = code;
// this.fieldName = fieldName;
// this.message = message;
// }
//
// public HyperwalletError(String code, String fieldName, String message, List<String> relatedResources) {
// this.code = code;
// this.fieldName = fieldName;
// this.message = message;
// this.relatedResources = relatedResources;
// }
//
// public String getCode() {
// return code;
// }
//
// public String getFieldName() {
// return fieldName;
// }
//
// public String getMessage() {
// return message;
// }
//
// public List<String> getRelatedResources() {
// return relatedResources;
// }
// }
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletErrorList.java
// @XmlRootElement
// public class HyperwalletErrorList {
//
// public List<HyperwalletError> errors = new ArrayList<HyperwalletError>();
//
// public HyperwalletErrorList() {
// }
//
// public List<HyperwalletError> getErrors() {
// return errors;
// }
//
// public void setErrors(List<HyperwalletError> errors) {
// this.errors = errors;
// }
// }
// Path: src/main/java/com/hyperwallet/clientsdk/HyperwalletException.java
import cc.protea.util.http.Response;
import com.hyperwallet.clientsdk.model.HyperwalletError;
import com.hyperwallet.clientsdk.model.HyperwalletErrorList;
import java.util.List;
package com.hyperwallet.clientsdk;
public class HyperwalletException extends RuntimeException {
private static final long serialVersionUID = 1L;
private Response response = null;
private String errorMessage;
private String errorCode;
private List<String> relatedResources;
private HyperwalletErrorList hyperwalletErrorList;
public HyperwalletException(final Exception e) {
super(e);
}
public HyperwalletException(final Response response, final int code, final String message) {
super(message);
this.response = response;
errorCode = Integer.toString(code);
errorMessage = message;
}
public HyperwalletException(final Response response, final int code, final String message, final Exception e) {
super(e);
this.response = response;
errorCode = Integer.toString(code);
errorMessage = message;
}
public HyperwalletException(final Response response, final HyperwalletErrorList hyperwalletErrorList) {
super(hyperwalletErrorList.getErrors().get(0).getMessage());
this.response = response;
this.hyperwalletErrorList = hyperwalletErrorList;
|
HyperwalletError error = this.hyperwalletErrorList.getErrors().get(0);
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/model/HyperwalletUserTest.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletUser.java
// public enum TaxVerificationStatus {NOT_REQUIRED, REQUIRED, UNDER_REVIEW, VERIFIED}
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletUser.java
// public static enum VerificationStatus {NOT_REQUIRED, REQUIRED, FAILED, UNDER_REVIEW, VERIFIED, REQUESTED}
|
import com.hyperwallet.clientsdk.model.HyperwalletUser.TaxVerificationStatus;
import com.hyperwallet.clientsdk.model.HyperwalletUser.VerificationStatus;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
|
package com.hyperwallet.clientsdk.model;
/**
* @author fkrauthan
*/
public class HyperwalletUserTest extends BaseModelTest<HyperwalletUser> {
@Override
protected HyperwalletUser createBaseModel() {
HyperwalletUser user = new HyperwalletUser();
HyperwalletVerificationDocument hyperwalletDocument = new HyperwalletVerificationDocument();
hyperwalletDocument.category("IDENTIFICATION").type("DRIVERS_LICENSE")
.country("US");
List<HyperwalletVerificationDocument> hyperwalletDocumentList = new ArrayList<>();
hyperwalletDocumentList.add(hyperwalletDocument);
List<HyperwalletLink> hyperwalletUserLinks = new ArrayList<>();
HyperwalletLink link = new HyperwalletLink();
hyperwalletUserLinks.add(link);
user
.token("test-token")
.status(HyperwalletUser.Status.ACTIVATED)
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletUser.java
// public enum TaxVerificationStatus {NOT_REQUIRED, REQUIRED, UNDER_REVIEW, VERIFIED}
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletUser.java
// public static enum VerificationStatus {NOT_REQUIRED, REQUIRED, FAILED, UNDER_REVIEW, VERIFIED, REQUESTED}
// Path: src/test/java/com/hyperwallet/clientsdk/model/HyperwalletUserTest.java
import com.hyperwallet.clientsdk.model.HyperwalletUser.TaxVerificationStatus;
import com.hyperwallet.clientsdk.model.HyperwalletUser.VerificationStatus;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
package com.hyperwallet.clientsdk.model;
/**
* @author fkrauthan
*/
public class HyperwalletUserTest extends BaseModelTest<HyperwalletUser> {
@Override
protected HyperwalletUser createBaseModel() {
HyperwalletUser user = new HyperwalletUser();
HyperwalletVerificationDocument hyperwalletDocument = new HyperwalletVerificationDocument();
hyperwalletDocument.category("IDENTIFICATION").type("DRIVERS_LICENSE")
.country("US");
List<HyperwalletVerificationDocument> hyperwalletDocumentList = new ArrayList<>();
hyperwalletDocumentList.add(hyperwalletDocument);
List<HyperwalletLink> hyperwalletUserLinks = new ArrayList<>();
HyperwalletLink link = new HyperwalletLink();
hyperwalletUserLinks.add(link);
user
.token("test-token")
.status(HyperwalletUser.Status.ACTIVATED)
|
.taxVerificationStatus(TaxVerificationStatus.REQUIRED)
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/model/HyperwalletUserTest.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletUser.java
// public enum TaxVerificationStatus {NOT_REQUIRED, REQUIRED, UNDER_REVIEW, VERIFIED}
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletUser.java
// public static enum VerificationStatus {NOT_REQUIRED, REQUIRED, FAILED, UNDER_REVIEW, VERIFIED, REQUESTED}
|
import com.hyperwallet.clientsdk.model.HyperwalletUser.TaxVerificationStatus;
import com.hyperwallet.clientsdk.model.HyperwalletUser.VerificationStatus;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
|
package com.hyperwallet.clientsdk.model;
/**
* @author fkrauthan
*/
public class HyperwalletUserTest extends BaseModelTest<HyperwalletUser> {
@Override
protected HyperwalletUser createBaseModel() {
HyperwalletUser user = new HyperwalletUser();
HyperwalletVerificationDocument hyperwalletDocument = new HyperwalletVerificationDocument();
hyperwalletDocument.category("IDENTIFICATION").type("DRIVERS_LICENSE")
.country("US");
List<HyperwalletVerificationDocument> hyperwalletDocumentList = new ArrayList<>();
hyperwalletDocumentList.add(hyperwalletDocument);
List<HyperwalletLink> hyperwalletUserLinks = new ArrayList<>();
HyperwalletLink link = new HyperwalletLink();
hyperwalletUserLinks.add(link);
user
.token("test-token")
.status(HyperwalletUser.Status.ACTIVATED)
.taxVerificationStatus(TaxVerificationStatus.REQUIRED)
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletUser.java
// public enum TaxVerificationStatus {NOT_REQUIRED, REQUIRED, UNDER_REVIEW, VERIFIED}
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletUser.java
// public static enum VerificationStatus {NOT_REQUIRED, REQUIRED, FAILED, UNDER_REVIEW, VERIFIED, REQUESTED}
// Path: src/test/java/com/hyperwallet/clientsdk/model/HyperwalletUserTest.java
import com.hyperwallet.clientsdk.model.HyperwalletUser.TaxVerificationStatus;
import com.hyperwallet.clientsdk.model.HyperwalletUser.VerificationStatus;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
package com.hyperwallet.clientsdk.model;
/**
* @author fkrauthan
*/
public class HyperwalletUserTest extends BaseModelTest<HyperwalletUser> {
@Override
protected HyperwalletUser createBaseModel() {
HyperwalletUser user = new HyperwalletUser();
HyperwalletVerificationDocument hyperwalletDocument = new HyperwalletVerificationDocument();
hyperwalletDocument.category("IDENTIFICATION").type("DRIVERS_LICENSE")
.country("US");
List<HyperwalletVerificationDocument> hyperwalletDocumentList = new ArrayList<>();
hyperwalletDocumentList.add(hyperwalletDocument);
List<HyperwalletLink> hyperwalletUserLinks = new ArrayList<>();
HyperwalletLink link = new HyperwalletLink();
hyperwalletUserLinks.add(link);
user
.token("test-token")
.status(HyperwalletUser.Status.ACTIVATED)
.taxVerificationStatus(TaxVerificationStatus.REQUIRED)
|
.verificationStatus(VerificationStatus.VERIFIED)
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethodListOptionsTest.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethod.java
// public enum Status {ACTIVATED, INVALID, DE_ACTIVATED}
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethod.java
// public enum Type {BANK_ACCOUNT, WIRE_ACCOUNT, PREPAID_CARD, BANK_CARD, PAPER_CHECK, PAYPAL_ACCOUNT, VENMO_ACCOUNT}
|
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.Status;
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.Type;
import java.util.Date;
|
package com.hyperwallet.clientsdk.model;
public class HyperwalletTransferMethodListOptionsTest extends BaseModelTest<HyperwalletTransferMethodListOptions> {
protected HyperwalletTransferMethodListOptions createBaseModel() {
HyperwalletTransferMethodListOptions options = new HyperwalletTransferMethodListOptions();
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethod.java
// public enum Status {ACTIVATED, INVALID, DE_ACTIVATED}
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethod.java
// public enum Type {BANK_ACCOUNT, WIRE_ACCOUNT, PREPAID_CARD, BANK_CARD, PAPER_CHECK, PAYPAL_ACCOUNT, VENMO_ACCOUNT}
// Path: src/test/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethodListOptionsTest.java
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.Status;
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.Type;
import java.util.Date;
package com.hyperwallet.clientsdk.model;
public class HyperwalletTransferMethodListOptionsTest extends BaseModelTest<HyperwalletTransferMethodListOptions> {
protected HyperwalletTransferMethodListOptions createBaseModel() {
HyperwalletTransferMethodListOptions options = new HyperwalletTransferMethodListOptions();
|
options.status(Status.ACTIVATED)
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethodListOptionsTest.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethod.java
// public enum Status {ACTIVATED, INVALID, DE_ACTIVATED}
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethod.java
// public enum Type {BANK_ACCOUNT, WIRE_ACCOUNT, PREPAID_CARD, BANK_CARD, PAPER_CHECK, PAYPAL_ACCOUNT, VENMO_ACCOUNT}
|
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.Status;
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.Type;
import java.util.Date;
|
package com.hyperwallet.clientsdk.model;
public class HyperwalletTransferMethodListOptionsTest extends BaseModelTest<HyperwalletTransferMethodListOptions> {
protected HyperwalletTransferMethodListOptions createBaseModel() {
HyperwalletTransferMethodListOptions options = new HyperwalletTransferMethodListOptions();
options.status(Status.ACTIVATED)
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethod.java
// public enum Status {ACTIVATED, INVALID, DE_ACTIVATED}
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethod.java
// public enum Type {BANK_ACCOUNT, WIRE_ACCOUNT, PREPAID_CARD, BANK_CARD, PAPER_CHECK, PAYPAL_ACCOUNT, VENMO_ACCOUNT}
// Path: src/test/java/com/hyperwallet/clientsdk/model/HyperwalletTransferMethodListOptionsTest.java
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.Status;
import com.hyperwallet.clientsdk.model.HyperwalletTransferMethod.Type;
import java.util.Date;
package com.hyperwallet.clientsdk.model;
public class HyperwalletTransferMethodListOptionsTest extends BaseModelTest<HyperwalletTransferMethodListOptions> {
protected HyperwalletTransferMethodListOptions createBaseModel() {
HyperwalletTransferMethodListOptions options = new HyperwalletTransferMethodListOptions();
options.status(Status.ACTIVATED)
|
.type(Type.PREPAID_CARD)
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/model/HyperwalletBankCardTest.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBankCard.java
// public enum Status {ACTIVATED, INVALID, VERIFIED, DE_ACTIVATED}
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBankCard.java
// public enum Type {BANK_CARD}
|
import com.hyperwallet.clientsdk.model.HyperwalletBankCard.Status;
import com.hyperwallet.clientsdk.model.HyperwalletBankCard.Type;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
|
package com.hyperwallet.clientsdk.model;
public class HyperwalletBankCardTest extends BaseModelTest<HyperwalletBankCard> {
protected HyperwalletBankCard createBaseModel() {
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
HyperwalletBankCard bankCard = new HyperwalletBankCard();
bankCard
.token("test-token")
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBankCard.java
// public enum Status {ACTIVATED, INVALID, VERIFIED, DE_ACTIVATED}
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBankCard.java
// public enum Type {BANK_CARD}
// Path: src/test/java/com/hyperwallet/clientsdk/model/HyperwalletBankCardTest.java
import com.hyperwallet.clientsdk.model.HyperwalletBankCard.Status;
import com.hyperwallet.clientsdk.model.HyperwalletBankCard.Type;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
package com.hyperwallet.clientsdk.model;
public class HyperwalletBankCardTest extends BaseModelTest<HyperwalletBankCard> {
protected HyperwalletBankCard createBaseModel() {
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
HyperwalletBankCard bankCard = new HyperwalletBankCard();
bankCard
.token("test-token")
|
.type(Type.BANK_CARD)
|
hyperwallet/java-sdk
|
src/test/java/com/hyperwallet/clientsdk/model/HyperwalletBankCardTest.java
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBankCard.java
// public enum Status {ACTIVATED, INVALID, VERIFIED, DE_ACTIVATED}
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBankCard.java
// public enum Type {BANK_CARD}
|
import com.hyperwallet.clientsdk.model.HyperwalletBankCard.Status;
import com.hyperwallet.clientsdk.model.HyperwalletBankCard.Type;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
|
package com.hyperwallet.clientsdk.model;
public class HyperwalletBankCardTest extends BaseModelTest<HyperwalletBankCard> {
protected HyperwalletBankCard createBaseModel() {
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
HyperwalletBankCard bankCard = new HyperwalletBankCard();
bankCard
.token("test-token")
.type(Type.BANK_CARD)
|
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBankCard.java
// public enum Status {ACTIVATED, INVALID, VERIFIED, DE_ACTIVATED}
//
// Path: src/main/java/com/hyperwallet/clientsdk/model/HyperwalletBankCard.java
// public enum Type {BANK_CARD}
// Path: src/test/java/com/hyperwallet/clientsdk/model/HyperwalletBankCardTest.java
import com.hyperwallet.clientsdk.model.HyperwalletBankCard.Status;
import com.hyperwallet.clientsdk.model.HyperwalletBankCard.Type;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
package com.hyperwallet.clientsdk.model;
public class HyperwalletBankCardTest extends BaseModelTest<HyperwalletBankCard> {
protected HyperwalletBankCard createBaseModel() {
List<HyperwalletLink> hyperwalletLinkList = new ArrayList<>();
HyperwalletLink hyperwalletLink = new HyperwalletLink();
hyperwalletLinkList.add(hyperwalletLink);
HyperwalletBankCard bankCard = new HyperwalletBankCard();
bankCard
.token("test-token")
.type(Type.BANK_CARD)
|
.status(Status.ACTIVATED)
|
powermock/powermock
|
tests/mockito/inline/src/test/java/samples/powermockito/inline/bugs/github793/PowerMockStaticMockingTest.java
|
// Path: tests/utils/src/main/java/org/powermock/api/mockito/MockitoVersion.java
// public class MockitoVersion {
//
// public static boolean isMockito1(){
// return MOCKITO_VERSION.isMockito1_0();
// }
//
// public static boolean isMockito2(){
// return MOCKITO_VERSION.isMockito2_0();
// }
//
// public static boolean isMockito3(){
// return MOCKITO_VERSION.isMockito3_0();
// }
//
// public static boolean isMockito4(){
// return MOCKITO_VERSION.isMockito4_0();
// }
//
// private static final MockitoVersion MOCKITO_VERSION = new MockitoVersion();
//
// private final String version;
//
// private MockitoVersion() {
// String ver = "";
// try {
// Class<?> mockitoClass = Class.forName("org.mockito.Mock");
// ProtectionDomain protectionDomain = mockitoClass.getProtectionDomain();
// CodeSource codeSource = protectionDomain.getCodeSource();
// String path = codeSource.getLocation().toString();
// int x = path.lastIndexOf("-");
// int y = path.lastIndexOf(".");
// ver = path.substring(x + 1, y);
// } catch (Exception e) {
// ver = "";
// } finally {
// version = ver;
// }
// }
//
//
// private boolean isMockito1_0() {
// return version.startsWith("1");
// }
//
// private boolean isMockito2_0() {
// return version.startsWith("2");
// }
//
// private boolean isMockito3_0() {
// return version.startsWith("3");
// }
//
// private boolean isMockito4_0() {
// return version.startsWith("4");
// }
// }
//
// Path: powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/PowerMockRunner.java
// public class PowerMockRunner extends AbstractCommonPowerMockRunner {
//
// public PowerMockRunner(Class<?> klass) throws Exception {
// super(klass, getRunnerDelegateImplClass(klass));
// }
//
// private static Class<? extends PowerMockJUnitRunnerDelegate> getRunnerDelegateImplClass(Class<?> klass) {
// if (klass.isAnnotationPresent(PowerMockRunnerDelegate.class)
// || Boolean.getBoolean("powermock.implicitDelegateAnnotation")) {
// return DelegatingPowerMockRunner.class;
// }
//
// Class<? extends PowerMockJUnitRunnerDelegate> concreteClass = PowerMockJUnit44RunnerDelegateImpl.class;
// if(JUnitVersion.isGreaterThanOrEqualTo("4.9")) {
// concreteClass = PowerMockJUnit49RunnerDelegateImpl.class;
// } else if( JUnitVersion.isGreaterThanOrEqualTo("4.7") ) {
// concreteClass = PowerMockJUnit47RunnerDelegateImpl.class;
// }
// return concreteClass;
// }
//
// /**
// * Clean up some state to avoid OOM issues
// */
// @Override
// public void run(RunNotifier notifier) {
// Description description = getDescription();
// try {
// super.run(notifier);
// } finally {
// Whitebox.setInternalState(description, "fAnnotations", new Annotation[]{});
// }
// }
// }
|
import static org.mockito.Mockito.when;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.exceptions.verification.NoInteractionsWanted;
import org.powermock.api.mockito.MockitoVersion;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.assertj.core.api.Java6Assertions.assertThatThrownBy;
import static org.junit.Assume.assumeTrue;
|
/*
*
* Copyright 2017 the original author or authors.
*
* Licensed 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 samples.powermockito.inline.bugs.github793;
@RunWith(PowerMockRunner.class)
@PrepareForTest(StaticClass.class)
public class PowerMockStaticMockingTest {
@Test
public void should_mock_static_method_when_mockito_inline_mock_creator_for_mockito_tests() {
assumeTrue("Test makes sense only for Mockito 2 & 3 & 4",
|
// Path: tests/utils/src/main/java/org/powermock/api/mockito/MockitoVersion.java
// public class MockitoVersion {
//
// public static boolean isMockito1(){
// return MOCKITO_VERSION.isMockito1_0();
// }
//
// public static boolean isMockito2(){
// return MOCKITO_VERSION.isMockito2_0();
// }
//
// public static boolean isMockito3(){
// return MOCKITO_VERSION.isMockito3_0();
// }
//
// public static boolean isMockito4(){
// return MOCKITO_VERSION.isMockito4_0();
// }
//
// private static final MockitoVersion MOCKITO_VERSION = new MockitoVersion();
//
// private final String version;
//
// private MockitoVersion() {
// String ver = "";
// try {
// Class<?> mockitoClass = Class.forName("org.mockito.Mock");
// ProtectionDomain protectionDomain = mockitoClass.getProtectionDomain();
// CodeSource codeSource = protectionDomain.getCodeSource();
// String path = codeSource.getLocation().toString();
// int x = path.lastIndexOf("-");
// int y = path.lastIndexOf(".");
// ver = path.substring(x + 1, y);
// } catch (Exception e) {
// ver = "";
// } finally {
// version = ver;
// }
// }
//
//
// private boolean isMockito1_0() {
// return version.startsWith("1");
// }
//
// private boolean isMockito2_0() {
// return version.startsWith("2");
// }
//
// private boolean isMockito3_0() {
// return version.startsWith("3");
// }
//
// private boolean isMockito4_0() {
// return version.startsWith("4");
// }
// }
//
// Path: powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/PowerMockRunner.java
// public class PowerMockRunner extends AbstractCommonPowerMockRunner {
//
// public PowerMockRunner(Class<?> klass) throws Exception {
// super(klass, getRunnerDelegateImplClass(klass));
// }
//
// private static Class<? extends PowerMockJUnitRunnerDelegate> getRunnerDelegateImplClass(Class<?> klass) {
// if (klass.isAnnotationPresent(PowerMockRunnerDelegate.class)
// || Boolean.getBoolean("powermock.implicitDelegateAnnotation")) {
// return DelegatingPowerMockRunner.class;
// }
//
// Class<? extends PowerMockJUnitRunnerDelegate> concreteClass = PowerMockJUnit44RunnerDelegateImpl.class;
// if(JUnitVersion.isGreaterThanOrEqualTo("4.9")) {
// concreteClass = PowerMockJUnit49RunnerDelegateImpl.class;
// } else if( JUnitVersion.isGreaterThanOrEqualTo("4.7") ) {
// concreteClass = PowerMockJUnit47RunnerDelegateImpl.class;
// }
// return concreteClass;
// }
//
// /**
// * Clean up some state to avoid OOM issues
// */
// @Override
// public void run(RunNotifier notifier) {
// Description description = getDescription();
// try {
// super.run(notifier);
// } finally {
// Whitebox.setInternalState(description, "fAnnotations", new Annotation[]{});
// }
// }
// }
// Path: tests/mockito/inline/src/test/java/samples/powermockito/inline/bugs/github793/PowerMockStaticMockingTest.java
import static org.mockito.Mockito.when;
import org.assertj.core.api.ThrowableAssert.ThrowingCallable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.exceptions.verification.NoInteractionsWanted;
import org.powermock.api.mockito.MockitoVersion;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.assertj.core.api.Java6Assertions.assertThatThrownBy;
import static org.junit.Assume.assumeTrue;
/*
*
* Copyright 2017 the original author or authors.
*
* Licensed 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 samples.powermockito.inline.bugs.github793;
@RunWith(PowerMockRunner.class)
@PrepareForTest(StaticClass.class)
public class PowerMockStaticMockingTest {
@Test
public void should_mock_static_method_when_mockito_inline_mock_creator_for_mockito_tests() {
assumeTrue("Test makes sense only for Mockito 2 & 3 & 4",
|
MockitoVersion.isMockito2() || MockitoVersion.isMockito3() || MockitoVersion.isMockito4());
|
powermock/powermock
|
powermock-api/powermock-api-mockito2/src/main/java/org/powermock/api/extension/listener/AnnotationEnabler.java
|
// Path: powermock-api/powermock-api-mockito2/src/main/java/org/powermock/api/mockito/internal/configuration/PowerMockitoInjectingAnnotationEngine.java
// public class PowerMockitoInjectingAnnotationEngine extends InjectingAnnotationEngine {
//
// @SuppressWarnings("deprecation")
// @Override
// public AutoCloseable process(Class<?> context, Object testClass) {
// // this will create @Spies:
// new PowerMockitoSpyAnnotationEngine().process(context, testClass);
//
// preLoadPluginLoader();
//
// // this injects mocks
// injectMocks(testClass);
// return null;
// }
//
// private void preLoadPluginLoader() {
// final ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
//
// Thread.currentThread().setContextClassLoader(DefaultMockCreator.class.getClassLoader());
//
// try {
// MockitoCore mc = new MockitoCore();
// Plugins.getMockMaker();
// } finally {
// Thread.currentThread().setContextClassLoader(originalCL);
// }
// }
// }
|
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Set;
import static org.mockito.Mockito.withSettings;
import static org.powermock.api.mockito.PowerMockito.mock;
import org.mockito.Answers;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockSettings;
import org.mockito.exceptions.base.MockitoException;
import org.mockito.internal.configuration.InjectingAnnotationEngine;
import org.mockito.internal.util.reflection.GenericMaster;
import org.powermock.api.mockito.internal.configuration.PowerMockitoInjectingAnnotationEngine;
import org.powermock.core.spi.listener.AnnotationEnablerListener;
import org.powermock.core.spi.support.AbstractPowerMockTestListenerBase;
import org.powermock.reflect.Whitebox;
import java.lang.annotation.Annotation;
|
/*
* Copyright 2016 the original author or authors.
*
* Licensed 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.powermock.api.extension.listener;
/**
* Before each test method all fields annotated with {@link Mock},
* {@link org.mockito.Mock} or {@link Mock} have mock objects created for them
* and injected to the fields. It will also delegate to a special implementation
* of the {@link InjectingAnnotationEngine} in Mockito which inject's spies,
* captors etc.
* <p/>
* It will only inject to fields that haven't been set before (i.e that are
* {@code null}).
*/
@SuppressWarnings("deprecation")
public class AnnotationEnabler extends AbstractPowerMockTestListenerBase implements AnnotationEnablerListener {
@Override
public void beforeTestMethod(Object testInstance, Method method, Object[] arguments) throws Exception {
standardInject(testInstance);
injectSpiesAndInjectToSetters(testInstance);
injectCaptor(testInstance);
}
private void injectSpiesAndInjectToSetters(Object testInstance) {
|
// Path: powermock-api/powermock-api-mockito2/src/main/java/org/powermock/api/mockito/internal/configuration/PowerMockitoInjectingAnnotationEngine.java
// public class PowerMockitoInjectingAnnotationEngine extends InjectingAnnotationEngine {
//
// @SuppressWarnings("deprecation")
// @Override
// public AutoCloseable process(Class<?> context, Object testClass) {
// // this will create @Spies:
// new PowerMockitoSpyAnnotationEngine().process(context, testClass);
//
// preLoadPluginLoader();
//
// // this injects mocks
// injectMocks(testClass);
// return null;
// }
//
// private void preLoadPluginLoader() {
// final ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
//
// Thread.currentThread().setContextClassLoader(DefaultMockCreator.class.getClassLoader());
//
// try {
// MockitoCore mc = new MockitoCore();
// Plugins.getMockMaker();
// } finally {
// Thread.currentThread().setContextClassLoader(originalCL);
// }
// }
// }
// Path: powermock-api/powermock-api-mockito2/src/main/java/org/powermock/api/extension/listener/AnnotationEnabler.java
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Set;
import static org.mockito.Mockito.withSettings;
import static org.powermock.api.mockito.PowerMockito.mock;
import org.mockito.Answers;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.MockSettings;
import org.mockito.exceptions.base.MockitoException;
import org.mockito.internal.configuration.InjectingAnnotationEngine;
import org.mockito.internal.util.reflection.GenericMaster;
import org.powermock.api.mockito.internal.configuration.PowerMockitoInjectingAnnotationEngine;
import org.powermock.core.spi.listener.AnnotationEnablerListener;
import org.powermock.core.spi.support.AbstractPowerMockTestListenerBase;
import org.powermock.reflect.Whitebox;
import java.lang.annotation.Annotation;
/*
* Copyright 2016 the original author or authors.
*
* Licensed 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.powermock.api.extension.listener;
/**
* Before each test method all fields annotated with {@link Mock},
* {@link org.mockito.Mock} or {@link Mock} have mock objects created for them
* and injected to the fields. It will also delegate to a special implementation
* of the {@link InjectingAnnotationEngine} in Mockito which inject's spies,
* captors etc.
* <p/>
* It will only inject to fields that haven't been set before (i.e that are
* {@code null}).
*/
@SuppressWarnings("deprecation")
public class AnnotationEnabler extends AbstractPowerMockTestListenerBase implements AnnotationEnablerListener {
@Override
public void beforeTestMethod(Object testInstance, Method method, Object[] arguments) throws Exception {
standardInject(testInstance);
injectSpiesAndInjectToSetters(testInstance);
injectCaptor(testInstance);
}
private void injectSpiesAndInjectToSetters(Object testInstance) {
|
new PowerMockitoInjectingAnnotationEngine().process(testInstance.getClass(), testInstance);
|
powermock/powermock
|
tests/junit4/src/test/java/samples/powermockito/junit4/bugs/github733/UseTestAnnotatedTest.java
|
// Path: powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/PowerMockRunner.java
// public class PowerMockRunner extends AbstractCommonPowerMockRunner {
//
// public PowerMockRunner(Class<?> klass) throws Exception {
// super(klass, getRunnerDelegateImplClass(klass));
// }
//
// private static Class<? extends PowerMockJUnitRunnerDelegate> getRunnerDelegateImplClass(Class<?> klass) {
// if (klass.isAnnotationPresent(PowerMockRunnerDelegate.class)
// || Boolean.getBoolean("powermock.implicitDelegateAnnotation")) {
// return DelegatingPowerMockRunner.class;
// }
//
// Class<? extends PowerMockJUnitRunnerDelegate> concreteClass = PowerMockJUnit44RunnerDelegateImpl.class;
// if(JUnitVersion.isGreaterThanOrEqualTo("4.9")) {
// concreteClass = PowerMockJUnit49RunnerDelegateImpl.class;
// } else if( JUnitVersion.isGreaterThanOrEqualTo("4.7") ) {
// concreteClass = PowerMockJUnit47RunnerDelegateImpl.class;
// }
// return concreteClass;
// }
//
// /**
// * Clean up some state to avoid OOM issues
// */
// @Override
// public void run(RunNotifier notifier) {
// Description description = getDescription();
// try {
// super.run(notifier);
// } finally {
// Whitebox.setInternalState(description, "fAnnotations", new Annotation[]{});
// }
// }
// }
|
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.internal.runners.TestClass;
import org.junit.runner.RunWith;
import org.powermock.modules.junit4.PowerMockRunner;
|
package samples.powermockito.junit4.bugs.github733;
@RunWith(Enclosed.class)
public class UseTestAnnotatedTest extends TestClass {
public UseTestAnnotatedTest(Class<MethodToTest> klass) {
super(klass);
}
|
// Path: powermock-modules/powermock-module-junit4/src/main/java/org/powermock/modules/junit4/PowerMockRunner.java
// public class PowerMockRunner extends AbstractCommonPowerMockRunner {
//
// public PowerMockRunner(Class<?> klass) throws Exception {
// super(klass, getRunnerDelegateImplClass(klass));
// }
//
// private static Class<? extends PowerMockJUnitRunnerDelegate> getRunnerDelegateImplClass(Class<?> klass) {
// if (klass.isAnnotationPresent(PowerMockRunnerDelegate.class)
// || Boolean.getBoolean("powermock.implicitDelegateAnnotation")) {
// return DelegatingPowerMockRunner.class;
// }
//
// Class<? extends PowerMockJUnitRunnerDelegate> concreteClass = PowerMockJUnit44RunnerDelegateImpl.class;
// if(JUnitVersion.isGreaterThanOrEqualTo("4.9")) {
// concreteClass = PowerMockJUnit49RunnerDelegateImpl.class;
// } else if( JUnitVersion.isGreaterThanOrEqualTo("4.7") ) {
// concreteClass = PowerMockJUnit47RunnerDelegateImpl.class;
// }
// return concreteClass;
// }
//
// /**
// * Clean up some state to avoid OOM issues
// */
// @Override
// public void run(RunNotifier notifier) {
// Description description = getDescription();
// try {
// super.run(notifier);
// } finally {
// Whitebox.setInternalState(description, "fAnnotations", new Annotation[]{});
// }
// }
// }
// Path: tests/junit4/src/test/java/samples/powermockito/junit4/bugs/github733/UseTestAnnotatedTest.java
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.internal.runners.TestClass;
import org.junit.runner.RunWith;
import org.powermock.modules.junit4.PowerMockRunner;
package samples.powermockito.junit4.bugs.github733;
@RunWith(Enclosed.class)
public class UseTestAnnotatedTest extends TestClass {
public UseTestAnnotatedTest(Class<MethodToTest> klass) {
super(klass);
}
|
@RunWith(PowerMockRunner.class)
|
idega/com.idega.block.staff
|
src/java/com/idega/block/staff/business/StaffFinder.java
|
// Path: src/java/com/idega/block/staff/data/StaffEntity.java
// public interface StaffEntity extends com.idega.data.IDOLegacyEntity
// {
// public void delete()throws java.sql.SQLException;
// public java.sql.Date getBeganWork();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setImageID(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffInfo.java
// public interface StaffInfo extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.sql.Date getBeganWork();
// public java.lang.String getEducation();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public java.lang.String getSchool();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setEducation(java.lang.String p0);
// public void setImageID(int p0);
// public void setSchool(java.lang.String p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffLocalized.java
// public interface StaffLocalized extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.lang.String getEducation();
// public int getLocaleId();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setEducation(java.lang.String p0);
// public void setLocaleId(int p0);
// public void setLocaleId(java.lang.Integer p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMeta.java
// public interface StaffMeta extends com.idega.block.staff.data.StaffMetaData
// {
// public int getLocaleId();
// public void setLocaleId(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaData.java
// public interface StaffMetaData extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getAttribute();
// public int getUserID();
// public java.lang.String getValue();
// public void setAttribute(java.lang.String p0);
// public void setUserID(int p0);
// public void setValue(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaDataBMPBean.java
// public class StaffMetaDataBMPBean extends com.idega.data.GenericEntity implements com.idega.block.staff.data.StaffMetaData {
//
// private static String sClassName = StaffMetaData.class.getName();
//
// public StaffMetaDataBMPBean(){
// super();
// }
//
// public StaffMetaDataBMPBean(int id)throws SQLException{
// super(id);
// }
//
//
// public String getEntityName(){
// return "st_staff_meta_data";
// }
//
// public void initializeAttributes(){
// addAttribute(getColumnNameUserID(),"User",true,true,"java.lang.Integer","many-to-one","com.idega.core.user.data.User");
// addAttribute(getColumnNameAttribute(),"Attribute",true,true,"java.lang.String");
// addAttribute(getColumnNameValue(),"Value",true,true,"java.lang.String");
// }
//
//
// public static StaffMetaData getStaticInstance(){
// return (StaffMetaData)GenericEntity.getStaticInstance(sClassName);
// }
//
//
// /* ColumnNames begin */
//
// public static String getColumnNameUserID(){return UserBMPBean.getColumnNameUserID();}
// public static String getColumnNameAttribute(){return "meta_attribute";}
// public static String getColumnNameValue(){return "meta_value";}
//
// /* ColumnNames end */
//
//
// /* Getters begin */
//
// public int getUserID() {
// return getIntColumnValue(getColumnNameUserID());
// }
//
// public String getAttribute() {
// return (String) getColumnValue(getColumnNameAttribute());
// }
//
// public String getValue() {
// return (String) getColumnValue(getColumnNameValue());
// }
//
// /* Getters end */
//
//
// /* Setters begin */
// public void setUserID(int userID) {
// setColumn(getColumnNameUserID(),userID);
// }
//
// public void setAttribute(String attribute) {
// setColumn(getColumnNameAttribute(),attribute);
// }
//
// public void setValue(String value) {
// setColumn(getColumnNameValue(),value);
// }
//
// }
|
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import com.idega.block.staff.data.StaffEntity;
import com.idega.block.staff.data.StaffInfo;
import com.idega.block.staff.data.StaffLocalized;
import com.idega.block.staff.data.StaffMeta;
import com.idega.block.staff.data.StaffMetaData;
import com.idega.block.staff.data.StaffMetaDataBMPBean;
import com.idega.core.contact.data.Email;
import com.idega.core.contact.data.Phone;
import com.idega.core.data.GenericGroup;
import com.idega.core.localisation.business.ICLocaleBusiness;
import com.idega.core.user.business.UserBusiness;
import com.idega.core.user.business.UserGroupBusiness;
import com.idega.core.user.data.User;
import com.idega.data.EntityFinder;
import com.idega.data.GenericEntity;
import com.idega.presentation.IWContext;
import com.idega.user.data.Group;
import com.idega.user.data.UserBMPBean;
import com.idega.util.IWTimestamp;
|
}
catch (Exception e) {
return null;
}
}
public static List getUsersInNoGroups() {
try {
return UserBusiness.getUsersInNoGroup();
}
catch (SQLException e) {
return null;
}
}
|
// Path: src/java/com/idega/block/staff/data/StaffEntity.java
// public interface StaffEntity extends com.idega.data.IDOLegacyEntity
// {
// public void delete()throws java.sql.SQLException;
// public java.sql.Date getBeganWork();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setImageID(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffInfo.java
// public interface StaffInfo extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.sql.Date getBeganWork();
// public java.lang.String getEducation();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public java.lang.String getSchool();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setEducation(java.lang.String p0);
// public void setImageID(int p0);
// public void setSchool(java.lang.String p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffLocalized.java
// public interface StaffLocalized extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.lang.String getEducation();
// public int getLocaleId();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setEducation(java.lang.String p0);
// public void setLocaleId(int p0);
// public void setLocaleId(java.lang.Integer p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMeta.java
// public interface StaffMeta extends com.idega.block.staff.data.StaffMetaData
// {
// public int getLocaleId();
// public void setLocaleId(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaData.java
// public interface StaffMetaData extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getAttribute();
// public int getUserID();
// public java.lang.String getValue();
// public void setAttribute(java.lang.String p0);
// public void setUserID(int p0);
// public void setValue(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaDataBMPBean.java
// public class StaffMetaDataBMPBean extends com.idega.data.GenericEntity implements com.idega.block.staff.data.StaffMetaData {
//
// private static String sClassName = StaffMetaData.class.getName();
//
// public StaffMetaDataBMPBean(){
// super();
// }
//
// public StaffMetaDataBMPBean(int id)throws SQLException{
// super(id);
// }
//
//
// public String getEntityName(){
// return "st_staff_meta_data";
// }
//
// public void initializeAttributes(){
// addAttribute(getColumnNameUserID(),"User",true,true,"java.lang.Integer","many-to-one","com.idega.core.user.data.User");
// addAttribute(getColumnNameAttribute(),"Attribute",true,true,"java.lang.String");
// addAttribute(getColumnNameValue(),"Value",true,true,"java.lang.String");
// }
//
//
// public static StaffMetaData getStaticInstance(){
// return (StaffMetaData)GenericEntity.getStaticInstance(sClassName);
// }
//
//
// /* ColumnNames begin */
//
// public static String getColumnNameUserID(){return UserBMPBean.getColumnNameUserID();}
// public static String getColumnNameAttribute(){return "meta_attribute";}
// public static String getColumnNameValue(){return "meta_value";}
//
// /* ColumnNames end */
//
//
// /* Getters begin */
//
// public int getUserID() {
// return getIntColumnValue(getColumnNameUserID());
// }
//
// public String getAttribute() {
// return (String) getColumnValue(getColumnNameAttribute());
// }
//
// public String getValue() {
// return (String) getColumnValue(getColumnNameValue());
// }
//
// /* Getters end */
//
//
// /* Setters begin */
// public void setUserID(int userID) {
// setColumn(getColumnNameUserID(),userID);
// }
//
// public void setAttribute(String attribute) {
// setColumn(getColumnNameAttribute(),attribute);
// }
//
// public void setValue(String value) {
// setColumn(getColumnNameValue(),value);
// }
//
// }
// Path: src/java/com/idega/block/staff/business/StaffFinder.java
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import com.idega.block.staff.data.StaffEntity;
import com.idega.block.staff.data.StaffInfo;
import com.idega.block.staff.data.StaffLocalized;
import com.idega.block.staff.data.StaffMeta;
import com.idega.block.staff.data.StaffMetaData;
import com.idega.block.staff.data.StaffMetaDataBMPBean;
import com.idega.core.contact.data.Email;
import com.idega.core.contact.data.Phone;
import com.idega.core.data.GenericGroup;
import com.idega.core.localisation.business.ICLocaleBusiness;
import com.idega.core.user.business.UserBusiness;
import com.idega.core.user.business.UserGroupBusiness;
import com.idega.core.user.data.User;
import com.idega.data.EntityFinder;
import com.idega.data.GenericEntity;
import com.idega.presentation.IWContext;
import com.idega.user.data.Group;
import com.idega.user.data.UserBMPBean;
import com.idega.util.IWTimestamp;
}
catch (Exception e) {
return null;
}
}
public static List getUsersInNoGroups() {
try {
return UserBusiness.getUsersInNoGroup();
}
catch (SQLException e) {
return null;
}
}
|
public static StaffLocalized getLocalizedStaff(StaffEntity entity, int iLocaleID){
|
idega/com.idega.block.staff
|
src/java/com/idega/block/staff/presentation/StaffUserTab.java
|
// Path: src/java/com/idega/block/staff/business/StaffUserBusiness.java
// public interface StaffUserBusiness extends UserBusiness {
//
// public static final String PARAMETER_USER_ID = "st_user_id";
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getGroups
// */
// public Collection getGroups(Group parentGroup)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserEducation
// */
// public String getUserEducation(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserTitle
// */
// public String getUserTitle(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserArea
// */
// public String getUserArea(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getBeganWork
// */
// public Date getBeganWork(User user) throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#storeStaffUser
// */
// public void storeStaffUser(User user, String education, String title,
// String area, Date beganWork, Locale locale)
// throws java.rmi.RemoteException;
//
// }
|
import java.rmi.RemoteException;
import java.sql.Date;
import java.util.Locale;
import com.idega.block.staff.business.StaffUserBusiness;
import com.idega.business.IBOLookup;
import com.idega.business.IBOLookupException;
import com.idega.business.IBORuntimeException;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.idegaweb.help.presentation.Help;
import com.idega.presentation.IWContext;
import com.idega.presentation.Image;
import com.idega.presentation.Table;
import com.idega.presentation.text.Break;
import com.idega.presentation.text.Text;
import com.idega.presentation.ui.DateInput;
import com.idega.presentation.ui.TextArea;
import com.idega.presentation.ui.TextInput;
import com.idega.user.business.UserConstants;
import com.idega.user.data.User;
import com.idega.user.presentation.UserTab;
import com.idega.util.IWTimestamp;
|
return false;
}
catch (RemoteException re) {
re.printStackTrace();
return false;
}
}
public void initFieldContents() {
try {
User user = getUser();
IWContext iwc = IWContext.getInstance();
Locale locale = iwc.getCurrentLocale();
String education = getBusiness(iwc).getUserEducation(user, locale);
String title = getBusiness(iwc).getUserTitle(user, locale);
String area = getBusiness(iwc).getUserArea(user, locale);
Date beganWork = getBusiness(iwc).getBeganWork(user);
this.fieldValues.put(this.educationFieldName, (education != null) ? education : "");
this.fieldValues.put(this.titleFieldName, (title != null) ? title : "");
this.fieldValues.put(this.areaFieldName, (area != null) ? area : "");
this.fieldValues.put(this.beganWorkFieldName, beganWork);
updateFieldsDisplayStatus();
}
catch (Exception e) {
System.err.println("GeneralUserInfoTab error initFieldContents, userId : " + getUserId());
}
}
|
// Path: src/java/com/idega/block/staff/business/StaffUserBusiness.java
// public interface StaffUserBusiness extends UserBusiness {
//
// public static final String PARAMETER_USER_ID = "st_user_id";
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getGroups
// */
// public Collection getGroups(Group parentGroup)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserEducation
// */
// public String getUserEducation(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserTitle
// */
// public String getUserTitle(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserArea
// */
// public String getUserArea(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getBeganWork
// */
// public Date getBeganWork(User user) throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#storeStaffUser
// */
// public void storeStaffUser(User user, String education, String title,
// String area, Date beganWork, Locale locale)
// throws java.rmi.RemoteException;
//
// }
// Path: src/java/com/idega/block/staff/presentation/StaffUserTab.java
import java.rmi.RemoteException;
import java.sql.Date;
import java.util.Locale;
import com.idega.block.staff.business.StaffUserBusiness;
import com.idega.business.IBOLookup;
import com.idega.business.IBOLookupException;
import com.idega.business.IBORuntimeException;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.idegaweb.help.presentation.Help;
import com.idega.presentation.IWContext;
import com.idega.presentation.Image;
import com.idega.presentation.Table;
import com.idega.presentation.text.Break;
import com.idega.presentation.text.Text;
import com.idega.presentation.ui.DateInput;
import com.idega.presentation.ui.TextArea;
import com.idega.presentation.ui.TextInput;
import com.idega.user.business.UserConstants;
import com.idega.user.data.User;
import com.idega.user.presentation.UserTab;
import com.idega.util.IWTimestamp;
return false;
}
catch (RemoteException re) {
re.printStackTrace();
return false;
}
}
public void initFieldContents() {
try {
User user = getUser();
IWContext iwc = IWContext.getInstance();
Locale locale = iwc.getCurrentLocale();
String education = getBusiness(iwc).getUserEducation(user, locale);
String title = getBusiness(iwc).getUserTitle(user, locale);
String area = getBusiness(iwc).getUserArea(user, locale);
Date beganWork = getBusiness(iwc).getBeganWork(user);
this.fieldValues.put(this.educationFieldName, (education != null) ? education : "");
this.fieldValues.put(this.titleFieldName, (title != null) ? title : "");
this.fieldValues.put(this.areaFieldName, (area != null) ? area : "");
this.fieldValues.put(this.beganWorkFieldName, beganWork);
updateFieldsDisplayStatus();
}
catch (Exception e) {
System.err.println("GeneralUserInfoTab error initFieldContents, userId : " + getUserId());
}
}
|
private StaffUserBusiness getBusiness(IWApplicationContext iwac) {
|
idega/com.idega.block.staff
|
src/java/com/idega/block/staff/business/StaffBusiness.java
|
// Path: src/java/com/idega/block/staff/data/StaffEntity.java
// public interface StaffEntity extends com.idega.data.IDOLegacyEntity
// {
// public void delete()throws java.sql.SQLException;
// public java.sql.Date getBeganWork();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setImageID(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffInfo.java
// public interface StaffInfo extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.sql.Date getBeganWork();
// public java.lang.String getEducation();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public java.lang.String getSchool();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setEducation(java.lang.String p0);
// public void setImageID(int p0);
// public void setSchool(java.lang.String p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffLocalized.java
// public interface StaffLocalized extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.lang.String getEducation();
// public int getLocaleId();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setEducation(java.lang.String p0);
// public void setLocaleId(int p0);
// public void setLocaleId(java.lang.Integer p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMeta.java
// public interface StaffMeta extends com.idega.block.staff.data.StaffMetaData
// {
// public int getLocaleId();
// public void setLocaleId(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaData.java
// public interface StaffMetaData extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getAttribute();
// public int getUserID();
// public java.lang.String getValue();
// public void setAttribute(java.lang.String p0);
// public void setUserID(int p0);
// public void setValue(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaDataBMPBean.java
// public class StaffMetaDataBMPBean extends com.idega.data.GenericEntity implements com.idega.block.staff.data.StaffMetaData {
//
// private static String sClassName = StaffMetaData.class.getName();
//
// public StaffMetaDataBMPBean(){
// super();
// }
//
// public StaffMetaDataBMPBean(int id)throws SQLException{
// super(id);
// }
//
//
// public String getEntityName(){
// return "st_staff_meta_data";
// }
//
// public void initializeAttributes(){
// addAttribute(getColumnNameUserID(),"User",true,true,"java.lang.Integer","many-to-one","com.idega.core.user.data.User");
// addAttribute(getColumnNameAttribute(),"Attribute",true,true,"java.lang.String");
// addAttribute(getColumnNameValue(),"Value",true,true,"java.lang.String");
// }
//
//
// public static StaffMetaData getStaticInstance(){
// return (StaffMetaData)GenericEntity.getStaticInstance(sClassName);
// }
//
//
// /* ColumnNames begin */
//
// public static String getColumnNameUserID(){return UserBMPBean.getColumnNameUserID();}
// public static String getColumnNameAttribute(){return "meta_attribute";}
// public static String getColumnNameValue(){return "meta_value";}
//
// /* ColumnNames end */
//
//
// /* Getters begin */
//
// public int getUserID() {
// return getIntColumnValue(getColumnNameUserID());
// }
//
// public String getAttribute() {
// return (String) getColumnValue(getColumnNameAttribute());
// }
//
// public String getValue() {
// return (String) getColumnValue(getColumnNameValue());
// }
//
// /* Getters end */
//
//
// /* Setters begin */
// public void setUserID(int userID) {
// setColumn(getColumnNameUserID(),userID);
// }
//
// public void setAttribute(String attribute) {
// setColumn(getColumnNameAttribute(),attribute);
// }
//
// public void setValue(String value) {
// setColumn(getColumnNameValue(),value);
// }
//
// }
|
import java.rmi.RemoteException;
import java.sql.SQLException;
import javax.transaction.TransactionManager;
import com.idega.block.staff.data.StaffEntity;
import com.idega.block.staff.data.StaffInfo;
import com.idega.block.staff.data.StaffLocalized;
import com.idega.block.staff.data.StaffMeta;
import com.idega.block.staff.data.StaffMetaData;
import com.idega.block.staff.data.StaffMetaDataBMPBean;
import com.idega.core.user.business.UserBusiness;
import com.idega.core.user.business.UserGroupBusiness;
import com.idega.data.GenericEntity;
import com.idega.transaction.IdegaTransactionManager;
import com.idega.util.IWTimestamp;
|
staffToAdd.setSchool(school);
}
if(area != null){
staffToAdd.setArea(area);
}
if(began_work != null){
staffToAdd.setBeganWork(began_work.getSQLDate());
}
// if(!update){
//
// staffToAdd.setImageID(-1);
//
// }
staffToAdd.store();
}
public static void saveStaff(int localeID, int userID, String title, String education, String area, IWTimestamp began_work, String imageID) {
|
// Path: src/java/com/idega/block/staff/data/StaffEntity.java
// public interface StaffEntity extends com.idega.data.IDOLegacyEntity
// {
// public void delete()throws java.sql.SQLException;
// public java.sql.Date getBeganWork();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setImageID(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffInfo.java
// public interface StaffInfo extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.sql.Date getBeganWork();
// public java.lang.String getEducation();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public java.lang.String getSchool();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setEducation(java.lang.String p0);
// public void setImageID(int p0);
// public void setSchool(java.lang.String p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffLocalized.java
// public interface StaffLocalized extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.lang.String getEducation();
// public int getLocaleId();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setEducation(java.lang.String p0);
// public void setLocaleId(int p0);
// public void setLocaleId(java.lang.Integer p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMeta.java
// public interface StaffMeta extends com.idega.block.staff.data.StaffMetaData
// {
// public int getLocaleId();
// public void setLocaleId(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaData.java
// public interface StaffMetaData extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getAttribute();
// public int getUserID();
// public java.lang.String getValue();
// public void setAttribute(java.lang.String p0);
// public void setUserID(int p0);
// public void setValue(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaDataBMPBean.java
// public class StaffMetaDataBMPBean extends com.idega.data.GenericEntity implements com.idega.block.staff.data.StaffMetaData {
//
// private static String sClassName = StaffMetaData.class.getName();
//
// public StaffMetaDataBMPBean(){
// super();
// }
//
// public StaffMetaDataBMPBean(int id)throws SQLException{
// super(id);
// }
//
//
// public String getEntityName(){
// return "st_staff_meta_data";
// }
//
// public void initializeAttributes(){
// addAttribute(getColumnNameUserID(),"User",true,true,"java.lang.Integer","many-to-one","com.idega.core.user.data.User");
// addAttribute(getColumnNameAttribute(),"Attribute",true,true,"java.lang.String");
// addAttribute(getColumnNameValue(),"Value",true,true,"java.lang.String");
// }
//
//
// public static StaffMetaData getStaticInstance(){
// return (StaffMetaData)GenericEntity.getStaticInstance(sClassName);
// }
//
//
// /* ColumnNames begin */
//
// public static String getColumnNameUserID(){return UserBMPBean.getColumnNameUserID();}
// public static String getColumnNameAttribute(){return "meta_attribute";}
// public static String getColumnNameValue(){return "meta_value";}
//
// /* ColumnNames end */
//
//
// /* Getters begin */
//
// public int getUserID() {
// return getIntColumnValue(getColumnNameUserID());
// }
//
// public String getAttribute() {
// return (String) getColumnValue(getColumnNameAttribute());
// }
//
// public String getValue() {
// return (String) getColumnValue(getColumnNameValue());
// }
//
// /* Getters end */
//
//
// /* Setters begin */
// public void setUserID(int userID) {
// setColumn(getColumnNameUserID(),userID);
// }
//
// public void setAttribute(String attribute) {
// setColumn(getColumnNameAttribute(),attribute);
// }
//
// public void setValue(String value) {
// setColumn(getColumnNameValue(),value);
// }
//
// }
// Path: src/java/com/idega/block/staff/business/StaffBusiness.java
import java.rmi.RemoteException;
import java.sql.SQLException;
import javax.transaction.TransactionManager;
import com.idega.block.staff.data.StaffEntity;
import com.idega.block.staff.data.StaffInfo;
import com.idega.block.staff.data.StaffLocalized;
import com.idega.block.staff.data.StaffMeta;
import com.idega.block.staff.data.StaffMetaData;
import com.idega.block.staff.data.StaffMetaDataBMPBean;
import com.idega.core.user.business.UserBusiness;
import com.idega.core.user.business.UserGroupBusiness;
import com.idega.data.GenericEntity;
import com.idega.transaction.IdegaTransactionManager;
import com.idega.util.IWTimestamp;
staffToAdd.setSchool(school);
}
if(area != null){
staffToAdd.setArea(area);
}
if(began_work != null){
staffToAdd.setBeganWork(began_work.getSQLDate());
}
// if(!update){
//
// staffToAdd.setImageID(-1);
//
// }
staffToAdd.store();
}
public static void saveStaff(int localeID, int userID, String title, String education, String area, IWTimestamp began_work, String imageID) {
|
StaffEntity staffToAdd = null;
|
idega/com.idega.block.staff
|
src/java/com/idega/block/staff/business/StaffBusiness.java
|
// Path: src/java/com/idega/block/staff/data/StaffEntity.java
// public interface StaffEntity extends com.idega.data.IDOLegacyEntity
// {
// public void delete()throws java.sql.SQLException;
// public java.sql.Date getBeganWork();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setImageID(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffInfo.java
// public interface StaffInfo extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.sql.Date getBeganWork();
// public java.lang.String getEducation();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public java.lang.String getSchool();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setEducation(java.lang.String p0);
// public void setImageID(int p0);
// public void setSchool(java.lang.String p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffLocalized.java
// public interface StaffLocalized extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.lang.String getEducation();
// public int getLocaleId();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setEducation(java.lang.String p0);
// public void setLocaleId(int p0);
// public void setLocaleId(java.lang.Integer p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMeta.java
// public interface StaffMeta extends com.idega.block.staff.data.StaffMetaData
// {
// public int getLocaleId();
// public void setLocaleId(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaData.java
// public interface StaffMetaData extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getAttribute();
// public int getUserID();
// public java.lang.String getValue();
// public void setAttribute(java.lang.String p0);
// public void setUserID(int p0);
// public void setValue(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaDataBMPBean.java
// public class StaffMetaDataBMPBean extends com.idega.data.GenericEntity implements com.idega.block.staff.data.StaffMetaData {
//
// private static String sClassName = StaffMetaData.class.getName();
//
// public StaffMetaDataBMPBean(){
// super();
// }
//
// public StaffMetaDataBMPBean(int id)throws SQLException{
// super(id);
// }
//
//
// public String getEntityName(){
// return "st_staff_meta_data";
// }
//
// public void initializeAttributes(){
// addAttribute(getColumnNameUserID(),"User",true,true,"java.lang.Integer","many-to-one","com.idega.core.user.data.User");
// addAttribute(getColumnNameAttribute(),"Attribute",true,true,"java.lang.String");
// addAttribute(getColumnNameValue(),"Value",true,true,"java.lang.String");
// }
//
//
// public static StaffMetaData getStaticInstance(){
// return (StaffMetaData)GenericEntity.getStaticInstance(sClassName);
// }
//
//
// /* ColumnNames begin */
//
// public static String getColumnNameUserID(){return UserBMPBean.getColumnNameUserID();}
// public static String getColumnNameAttribute(){return "meta_attribute";}
// public static String getColumnNameValue(){return "meta_value";}
//
// /* ColumnNames end */
//
//
// /* Getters begin */
//
// public int getUserID() {
// return getIntColumnValue(getColumnNameUserID());
// }
//
// public String getAttribute() {
// return (String) getColumnValue(getColumnNameAttribute());
// }
//
// public String getValue() {
// return (String) getColumnValue(getColumnNameValue());
// }
//
// /* Getters end */
//
//
// /* Setters begin */
// public void setUserID(int userID) {
// setColumn(getColumnNameUserID(),userID);
// }
//
// public void setAttribute(String attribute) {
// setColumn(getColumnNameAttribute(),attribute);
// }
//
// public void setValue(String value) {
// setColumn(getColumnNameValue(),value);
// }
//
// }
|
import java.rmi.RemoteException;
import java.sql.SQLException;
import javax.transaction.TransactionManager;
import com.idega.block.staff.data.StaffEntity;
import com.idega.block.staff.data.StaffInfo;
import com.idega.block.staff.data.StaffLocalized;
import com.idega.block.staff.data.StaffMeta;
import com.idega.block.staff.data.StaffMetaData;
import com.idega.block.staff.data.StaffMetaDataBMPBean;
import com.idega.core.user.business.UserBusiness;
import com.idega.core.user.business.UserGroupBusiness;
import com.idega.data.GenericEntity;
import com.idega.transaction.IdegaTransactionManager;
import com.idega.util.IWTimestamp;
|
if ( update ) {
try {
staffToAdd.update();
}
catch (SQLException e) {
e.printStackTrace(System.err);
}
}
else {
try {
staffToAdd.insert();
}
catch (SQLException e) {
e.printStackTrace(System.err);
}
}
|
// Path: src/java/com/idega/block/staff/data/StaffEntity.java
// public interface StaffEntity extends com.idega.data.IDOLegacyEntity
// {
// public void delete()throws java.sql.SQLException;
// public java.sql.Date getBeganWork();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setImageID(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffInfo.java
// public interface StaffInfo extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.sql.Date getBeganWork();
// public java.lang.String getEducation();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public java.lang.String getSchool();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setEducation(java.lang.String p0);
// public void setImageID(int p0);
// public void setSchool(java.lang.String p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffLocalized.java
// public interface StaffLocalized extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.lang.String getEducation();
// public int getLocaleId();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setEducation(java.lang.String p0);
// public void setLocaleId(int p0);
// public void setLocaleId(java.lang.Integer p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMeta.java
// public interface StaffMeta extends com.idega.block.staff.data.StaffMetaData
// {
// public int getLocaleId();
// public void setLocaleId(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaData.java
// public interface StaffMetaData extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getAttribute();
// public int getUserID();
// public java.lang.String getValue();
// public void setAttribute(java.lang.String p0);
// public void setUserID(int p0);
// public void setValue(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaDataBMPBean.java
// public class StaffMetaDataBMPBean extends com.idega.data.GenericEntity implements com.idega.block.staff.data.StaffMetaData {
//
// private static String sClassName = StaffMetaData.class.getName();
//
// public StaffMetaDataBMPBean(){
// super();
// }
//
// public StaffMetaDataBMPBean(int id)throws SQLException{
// super(id);
// }
//
//
// public String getEntityName(){
// return "st_staff_meta_data";
// }
//
// public void initializeAttributes(){
// addAttribute(getColumnNameUserID(),"User",true,true,"java.lang.Integer","many-to-one","com.idega.core.user.data.User");
// addAttribute(getColumnNameAttribute(),"Attribute",true,true,"java.lang.String");
// addAttribute(getColumnNameValue(),"Value",true,true,"java.lang.String");
// }
//
//
// public static StaffMetaData getStaticInstance(){
// return (StaffMetaData)GenericEntity.getStaticInstance(sClassName);
// }
//
//
// /* ColumnNames begin */
//
// public static String getColumnNameUserID(){return UserBMPBean.getColumnNameUserID();}
// public static String getColumnNameAttribute(){return "meta_attribute";}
// public static String getColumnNameValue(){return "meta_value";}
//
// /* ColumnNames end */
//
//
// /* Getters begin */
//
// public int getUserID() {
// return getIntColumnValue(getColumnNameUserID());
// }
//
// public String getAttribute() {
// return (String) getColumnValue(getColumnNameAttribute());
// }
//
// public String getValue() {
// return (String) getColumnValue(getColumnNameValue());
// }
//
// /* Getters end */
//
//
// /* Setters begin */
// public void setUserID(int userID) {
// setColumn(getColumnNameUserID(),userID);
// }
//
// public void setAttribute(String attribute) {
// setColumn(getColumnNameAttribute(),attribute);
// }
//
// public void setValue(String value) {
// setColumn(getColumnNameValue(),value);
// }
//
// }
// Path: src/java/com/idega/block/staff/business/StaffBusiness.java
import java.rmi.RemoteException;
import java.sql.SQLException;
import javax.transaction.TransactionManager;
import com.idega.block.staff.data.StaffEntity;
import com.idega.block.staff.data.StaffInfo;
import com.idega.block.staff.data.StaffLocalized;
import com.idega.block.staff.data.StaffMeta;
import com.idega.block.staff.data.StaffMetaData;
import com.idega.block.staff.data.StaffMetaDataBMPBean;
import com.idega.core.user.business.UserBusiness;
import com.idega.core.user.business.UserGroupBusiness;
import com.idega.data.GenericEntity;
import com.idega.transaction.IdegaTransactionManager;
import com.idega.util.IWTimestamp;
if ( update ) {
try {
staffToAdd.update();
}
catch (SQLException e) {
e.printStackTrace(System.err);
}
}
else {
try {
staffToAdd.insert();
}
catch (SQLException e) {
e.printStackTrace(System.err);
}
}
|
StaffLocalized locText = StaffFinder.getLocalizedStaff(staffToAdd,localeID);
|
idega/com.idega.block.staff
|
src/java/com/idega/block/staff/business/StaffBusiness.java
|
// Path: src/java/com/idega/block/staff/data/StaffEntity.java
// public interface StaffEntity extends com.idega.data.IDOLegacyEntity
// {
// public void delete()throws java.sql.SQLException;
// public java.sql.Date getBeganWork();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setImageID(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffInfo.java
// public interface StaffInfo extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.sql.Date getBeganWork();
// public java.lang.String getEducation();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public java.lang.String getSchool();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setEducation(java.lang.String p0);
// public void setImageID(int p0);
// public void setSchool(java.lang.String p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffLocalized.java
// public interface StaffLocalized extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.lang.String getEducation();
// public int getLocaleId();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setEducation(java.lang.String p0);
// public void setLocaleId(int p0);
// public void setLocaleId(java.lang.Integer p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMeta.java
// public interface StaffMeta extends com.idega.block.staff.data.StaffMetaData
// {
// public int getLocaleId();
// public void setLocaleId(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaData.java
// public interface StaffMetaData extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getAttribute();
// public int getUserID();
// public java.lang.String getValue();
// public void setAttribute(java.lang.String p0);
// public void setUserID(int p0);
// public void setValue(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaDataBMPBean.java
// public class StaffMetaDataBMPBean extends com.idega.data.GenericEntity implements com.idega.block.staff.data.StaffMetaData {
//
// private static String sClassName = StaffMetaData.class.getName();
//
// public StaffMetaDataBMPBean(){
// super();
// }
//
// public StaffMetaDataBMPBean(int id)throws SQLException{
// super(id);
// }
//
//
// public String getEntityName(){
// return "st_staff_meta_data";
// }
//
// public void initializeAttributes(){
// addAttribute(getColumnNameUserID(),"User",true,true,"java.lang.Integer","many-to-one","com.idega.core.user.data.User");
// addAttribute(getColumnNameAttribute(),"Attribute",true,true,"java.lang.String");
// addAttribute(getColumnNameValue(),"Value",true,true,"java.lang.String");
// }
//
//
// public static StaffMetaData getStaticInstance(){
// return (StaffMetaData)GenericEntity.getStaticInstance(sClassName);
// }
//
//
// /* ColumnNames begin */
//
// public static String getColumnNameUserID(){return UserBMPBean.getColumnNameUserID();}
// public static String getColumnNameAttribute(){return "meta_attribute";}
// public static String getColumnNameValue(){return "meta_value";}
//
// /* ColumnNames end */
//
//
// /* Getters begin */
//
// public int getUserID() {
// return getIntColumnValue(getColumnNameUserID());
// }
//
// public String getAttribute() {
// return (String) getColumnValue(getColumnNameAttribute());
// }
//
// public String getValue() {
// return (String) getColumnValue(getColumnNameValue());
// }
//
// /* Getters end */
//
//
// /* Setters begin */
// public void setUserID(int userID) {
// setColumn(getColumnNameUserID(),userID);
// }
//
// public void setAttribute(String attribute) {
// setColumn(getColumnNameAttribute(),attribute);
// }
//
// public void setValue(String value) {
// setColumn(getColumnNameValue(),value);
// }
//
// }
|
import java.rmi.RemoteException;
import java.sql.SQLException;
import javax.transaction.TransactionManager;
import com.idega.block.staff.data.StaffEntity;
import com.idega.block.staff.data.StaffInfo;
import com.idega.block.staff.data.StaffLocalized;
import com.idega.block.staff.data.StaffMeta;
import com.idega.block.staff.data.StaffMetaData;
import com.idega.block.staff.data.StaffMetaDataBMPBean;
import com.idega.core.user.business.UserBusiness;
import com.idega.core.user.business.UserGroupBusiness;
import com.idega.data.GenericEntity;
import com.idega.transaction.IdegaTransactionManager;
import com.idega.util.IWTimestamp;
|
try {
if ( update ) {
staffToAdd.update();
}
else {
staffToAdd.insert();
}
}
catch (SQLException ex) {
ex.printStackTrace(System.err);
}
}
public static void updateMetaData(int userID,String a1,String v1,String a2,String v2,String a3,String v3,String a4,String v4,String a5,String v5,String a6,String v6) {
try {
|
// Path: src/java/com/idega/block/staff/data/StaffEntity.java
// public interface StaffEntity extends com.idega.data.IDOLegacyEntity
// {
// public void delete()throws java.sql.SQLException;
// public java.sql.Date getBeganWork();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setImageID(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffInfo.java
// public interface StaffInfo extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.sql.Date getBeganWork();
// public java.lang.String getEducation();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public java.lang.String getSchool();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setEducation(java.lang.String p0);
// public void setImageID(int p0);
// public void setSchool(java.lang.String p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffLocalized.java
// public interface StaffLocalized extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.lang.String getEducation();
// public int getLocaleId();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setEducation(java.lang.String p0);
// public void setLocaleId(int p0);
// public void setLocaleId(java.lang.Integer p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMeta.java
// public interface StaffMeta extends com.idega.block.staff.data.StaffMetaData
// {
// public int getLocaleId();
// public void setLocaleId(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaData.java
// public interface StaffMetaData extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getAttribute();
// public int getUserID();
// public java.lang.String getValue();
// public void setAttribute(java.lang.String p0);
// public void setUserID(int p0);
// public void setValue(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaDataBMPBean.java
// public class StaffMetaDataBMPBean extends com.idega.data.GenericEntity implements com.idega.block.staff.data.StaffMetaData {
//
// private static String sClassName = StaffMetaData.class.getName();
//
// public StaffMetaDataBMPBean(){
// super();
// }
//
// public StaffMetaDataBMPBean(int id)throws SQLException{
// super(id);
// }
//
//
// public String getEntityName(){
// return "st_staff_meta_data";
// }
//
// public void initializeAttributes(){
// addAttribute(getColumnNameUserID(),"User",true,true,"java.lang.Integer","many-to-one","com.idega.core.user.data.User");
// addAttribute(getColumnNameAttribute(),"Attribute",true,true,"java.lang.String");
// addAttribute(getColumnNameValue(),"Value",true,true,"java.lang.String");
// }
//
//
// public static StaffMetaData getStaticInstance(){
// return (StaffMetaData)GenericEntity.getStaticInstance(sClassName);
// }
//
//
// /* ColumnNames begin */
//
// public static String getColumnNameUserID(){return UserBMPBean.getColumnNameUserID();}
// public static String getColumnNameAttribute(){return "meta_attribute";}
// public static String getColumnNameValue(){return "meta_value";}
//
// /* ColumnNames end */
//
//
// /* Getters begin */
//
// public int getUserID() {
// return getIntColumnValue(getColumnNameUserID());
// }
//
// public String getAttribute() {
// return (String) getColumnValue(getColumnNameAttribute());
// }
//
// public String getValue() {
// return (String) getColumnValue(getColumnNameValue());
// }
//
// /* Getters end */
//
//
// /* Setters begin */
// public void setUserID(int userID) {
// setColumn(getColumnNameUserID(),userID);
// }
//
// public void setAttribute(String attribute) {
// setColumn(getColumnNameAttribute(),attribute);
// }
//
// public void setValue(String value) {
// setColumn(getColumnNameValue(),value);
// }
//
// }
// Path: src/java/com/idega/block/staff/business/StaffBusiness.java
import java.rmi.RemoteException;
import java.sql.SQLException;
import javax.transaction.TransactionManager;
import com.idega.block.staff.data.StaffEntity;
import com.idega.block.staff.data.StaffInfo;
import com.idega.block.staff.data.StaffLocalized;
import com.idega.block.staff.data.StaffMeta;
import com.idega.block.staff.data.StaffMetaData;
import com.idega.block.staff.data.StaffMetaDataBMPBean;
import com.idega.core.user.business.UserBusiness;
import com.idega.core.user.business.UserGroupBusiness;
import com.idega.data.GenericEntity;
import com.idega.transaction.IdegaTransactionManager;
import com.idega.util.IWTimestamp;
try {
if ( update ) {
staffToAdd.update();
}
else {
staffToAdd.insert();
}
}
catch (SQLException ex) {
ex.printStackTrace(System.err);
}
}
public static void updateMetaData(int userID,String a1,String v1,String a2,String v2,String a3,String v3,String a4,String v4,String a5,String v5,String a6,String v6) {
try {
|
com.idega.block.staff.data.StaffMetaDataBMPBean.getStaticInstance().deleteMultiple(com.idega.block.staff.data.StaffMetaDataBMPBean.getColumnNameUserID(),Integer.toString(userID));
|
idega/com.idega.block.staff
|
src/java/com/idega/block/staff/business/StaffBusiness.java
|
// Path: src/java/com/idega/block/staff/data/StaffEntity.java
// public interface StaffEntity extends com.idega.data.IDOLegacyEntity
// {
// public void delete()throws java.sql.SQLException;
// public java.sql.Date getBeganWork();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setImageID(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffInfo.java
// public interface StaffInfo extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.sql.Date getBeganWork();
// public java.lang.String getEducation();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public java.lang.String getSchool();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setEducation(java.lang.String p0);
// public void setImageID(int p0);
// public void setSchool(java.lang.String p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffLocalized.java
// public interface StaffLocalized extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.lang.String getEducation();
// public int getLocaleId();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setEducation(java.lang.String p0);
// public void setLocaleId(int p0);
// public void setLocaleId(java.lang.Integer p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMeta.java
// public interface StaffMeta extends com.idega.block.staff.data.StaffMetaData
// {
// public int getLocaleId();
// public void setLocaleId(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaData.java
// public interface StaffMetaData extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getAttribute();
// public int getUserID();
// public java.lang.String getValue();
// public void setAttribute(java.lang.String p0);
// public void setUserID(int p0);
// public void setValue(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaDataBMPBean.java
// public class StaffMetaDataBMPBean extends com.idega.data.GenericEntity implements com.idega.block.staff.data.StaffMetaData {
//
// private static String sClassName = StaffMetaData.class.getName();
//
// public StaffMetaDataBMPBean(){
// super();
// }
//
// public StaffMetaDataBMPBean(int id)throws SQLException{
// super(id);
// }
//
//
// public String getEntityName(){
// return "st_staff_meta_data";
// }
//
// public void initializeAttributes(){
// addAttribute(getColumnNameUserID(),"User",true,true,"java.lang.Integer","many-to-one","com.idega.core.user.data.User");
// addAttribute(getColumnNameAttribute(),"Attribute",true,true,"java.lang.String");
// addAttribute(getColumnNameValue(),"Value",true,true,"java.lang.String");
// }
//
//
// public static StaffMetaData getStaticInstance(){
// return (StaffMetaData)GenericEntity.getStaticInstance(sClassName);
// }
//
//
// /* ColumnNames begin */
//
// public static String getColumnNameUserID(){return UserBMPBean.getColumnNameUserID();}
// public static String getColumnNameAttribute(){return "meta_attribute";}
// public static String getColumnNameValue(){return "meta_value";}
//
// /* ColumnNames end */
//
//
// /* Getters begin */
//
// public int getUserID() {
// return getIntColumnValue(getColumnNameUserID());
// }
//
// public String getAttribute() {
// return (String) getColumnValue(getColumnNameAttribute());
// }
//
// public String getValue() {
// return (String) getColumnValue(getColumnNameValue());
// }
//
// /* Getters end */
//
//
// /* Setters begin */
// public void setUserID(int userID) {
// setColumn(getColumnNameUserID(),userID);
// }
//
// public void setAttribute(String attribute) {
// setColumn(getColumnNameAttribute(),attribute);
// }
//
// public void setValue(String value) {
// setColumn(getColumnNameValue(),value);
// }
//
// }
|
import java.rmi.RemoteException;
import java.sql.SQLException;
import javax.transaction.TransactionManager;
import com.idega.block.staff.data.StaffEntity;
import com.idega.block.staff.data.StaffInfo;
import com.idega.block.staff.data.StaffLocalized;
import com.idega.block.staff.data.StaffMeta;
import com.idega.block.staff.data.StaffMetaData;
import com.idega.block.staff.data.StaffMetaDataBMPBean;
import com.idega.core.user.business.UserBusiness;
import com.idega.core.user.business.UserGroupBusiness;
import com.idega.data.GenericEntity;
import com.idega.transaction.IdegaTransactionManager;
import com.idega.util.IWTimestamp;
|
}
catch (SQLException ex) {
ex.printStackTrace(System.err);
}
}
public static void updateMetaData(int userID,String a1,String v1,String a2,String v2,String a3,String v3,String a4,String v4,String a5,String v5,String a6,String v6) {
try {
com.idega.block.staff.data.StaffMetaDataBMPBean.getStaticInstance().deleteMultiple(com.idega.block.staff.data.StaffMetaDataBMPBean.getColumnNameUserID(),Integer.toString(userID));
}
catch (SQLException e) {
e.printStackTrace(System.err);
}
TransactionManager t = IdegaTransactionManager.getInstance();
|
// Path: src/java/com/idega/block/staff/data/StaffEntity.java
// public interface StaffEntity extends com.idega.data.IDOLegacyEntity
// {
// public void delete()throws java.sql.SQLException;
// public java.sql.Date getBeganWork();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setImageID(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffInfo.java
// public interface StaffInfo extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.sql.Date getBeganWork();
// public java.lang.String getEducation();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public java.lang.String getSchool();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setEducation(java.lang.String p0);
// public void setImageID(int p0);
// public void setSchool(java.lang.String p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffLocalized.java
// public interface StaffLocalized extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.lang.String getEducation();
// public int getLocaleId();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setEducation(java.lang.String p0);
// public void setLocaleId(int p0);
// public void setLocaleId(java.lang.Integer p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMeta.java
// public interface StaffMeta extends com.idega.block.staff.data.StaffMetaData
// {
// public int getLocaleId();
// public void setLocaleId(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaData.java
// public interface StaffMetaData extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getAttribute();
// public int getUserID();
// public java.lang.String getValue();
// public void setAttribute(java.lang.String p0);
// public void setUserID(int p0);
// public void setValue(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaDataBMPBean.java
// public class StaffMetaDataBMPBean extends com.idega.data.GenericEntity implements com.idega.block.staff.data.StaffMetaData {
//
// private static String sClassName = StaffMetaData.class.getName();
//
// public StaffMetaDataBMPBean(){
// super();
// }
//
// public StaffMetaDataBMPBean(int id)throws SQLException{
// super(id);
// }
//
//
// public String getEntityName(){
// return "st_staff_meta_data";
// }
//
// public void initializeAttributes(){
// addAttribute(getColumnNameUserID(),"User",true,true,"java.lang.Integer","many-to-one","com.idega.core.user.data.User");
// addAttribute(getColumnNameAttribute(),"Attribute",true,true,"java.lang.String");
// addAttribute(getColumnNameValue(),"Value",true,true,"java.lang.String");
// }
//
//
// public static StaffMetaData getStaticInstance(){
// return (StaffMetaData)GenericEntity.getStaticInstance(sClassName);
// }
//
//
// /* ColumnNames begin */
//
// public static String getColumnNameUserID(){return UserBMPBean.getColumnNameUserID();}
// public static String getColumnNameAttribute(){return "meta_attribute";}
// public static String getColumnNameValue(){return "meta_value";}
//
// /* ColumnNames end */
//
//
// /* Getters begin */
//
// public int getUserID() {
// return getIntColumnValue(getColumnNameUserID());
// }
//
// public String getAttribute() {
// return (String) getColumnValue(getColumnNameAttribute());
// }
//
// public String getValue() {
// return (String) getColumnValue(getColumnNameValue());
// }
//
// /* Getters end */
//
//
// /* Setters begin */
// public void setUserID(int userID) {
// setColumn(getColumnNameUserID(),userID);
// }
//
// public void setAttribute(String attribute) {
// setColumn(getColumnNameAttribute(),attribute);
// }
//
// public void setValue(String value) {
// setColumn(getColumnNameValue(),value);
// }
//
// }
// Path: src/java/com/idega/block/staff/business/StaffBusiness.java
import java.rmi.RemoteException;
import java.sql.SQLException;
import javax.transaction.TransactionManager;
import com.idega.block.staff.data.StaffEntity;
import com.idega.block.staff.data.StaffInfo;
import com.idega.block.staff.data.StaffLocalized;
import com.idega.block.staff.data.StaffMeta;
import com.idega.block.staff.data.StaffMetaData;
import com.idega.block.staff.data.StaffMetaDataBMPBean;
import com.idega.core.user.business.UserBusiness;
import com.idega.core.user.business.UserGroupBusiness;
import com.idega.data.GenericEntity;
import com.idega.transaction.IdegaTransactionManager;
import com.idega.util.IWTimestamp;
}
catch (SQLException ex) {
ex.printStackTrace(System.err);
}
}
public static void updateMetaData(int userID,String a1,String v1,String a2,String v2,String a3,String v3,String a4,String v4,String a5,String v5,String a6,String v6) {
try {
com.idega.block.staff.data.StaffMetaDataBMPBean.getStaticInstance().deleteMultiple(com.idega.block.staff.data.StaffMetaDataBMPBean.getColumnNameUserID(),Integer.toString(userID));
}
catch (SQLException e) {
e.printStackTrace(System.err);
}
TransactionManager t = IdegaTransactionManager.getInstance();
|
StaffMetaData meta = null;
|
idega/com.idega.block.staff
|
src/java/com/idega/block/staff/business/StaffBusiness.java
|
// Path: src/java/com/idega/block/staff/data/StaffEntity.java
// public interface StaffEntity extends com.idega.data.IDOLegacyEntity
// {
// public void delete()throws java.sql.SQLException;
// public java.sql.Date getBeganWork();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setImageID(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffInfo.java
// public interface StaffInfo extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.sql.Date getBeganWork();
// public java.lang.String getEducation();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public java.lang.String getSchool();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setEducation(java.lang.String p0);
// public void setImageID(int p0);
// public void setSchool(java.lang.String p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffLocalized.java
// public interface StaffLocalized extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.lang.String getEducation();
// public int getLocaleId();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setEducation(java.lang.String p0);
// public void setLocaleId(int p0);
// public void setLocaleId(java.lang.Integer p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMeta.java
// public interface StaffMeta extends com.idega.block.staff.data.StaffMetaData
// {
// public int getLocaleId();
// public void setLocaleId(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaData.java
// public interface StaffMetaData extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getAttribute();
// public int getUserID();
// public java.lang.String getValue();
// public void setAttribute(java.lang.String p0);
// public void setUserID(int p0);
// public void setValue(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaDataBMPBean.java
// public class StaffMetaDataBMPBean extends com.idega.data.GenericEntity implements com.idega.block.staff.data.StaffMetaData {
//
// private static String sClassName = StaffMetaData.class.getName();
//
// public StaffMetaDataBMPBean(){
// super();
// }
//
// public StaffMetaDataBMPBean(int id)throws SQLException{
// super(id);
// }
//
//
// public String getEntityName(){
// return "st_staff_meta_data";
// }
//
// public void initializeAttributes(){
// addAttribute(getColumnNameUserID(),"User",true,true,"java.lang.Integer","many-to-one","com.idega.core.user.data.User");
// addAttribute(getColumnNameAttribute(),"Attribute",true,true,"java.lang.String");
// addAttribute(getColumnNameValue(),"Value",true,true,"java.lang.String");
// }
//
//
// public static StaffMetaData getStaticInstance(){
// return (StaffMetaData)GenericEntity.getStaticInstance(sClassName);
// }
//
//
// /* ColumnNames begin */
//
// public static String getColumnNameUserID(){return UserBMPBean.getColumnNameUserID();}
// public static String getColumnNameAttribute(){return "meta_attribute";}
// public static String getColumnNameValue(){return "meta_value";}
//
// /* ColumnNames end */
//
//
// /* Getters begin */
//
// public int getUserID() {
// return getIntColumnValue(getColumnNameUserID());
// }
//
// public String getAttribute() {
// return (String) getColumnValue(getColumnNameAttribute());
// }
//
// public String getValue() {
// return (String) getColumnValue(getColumnNameValue());
// }
//
// /* Getters end */
//
//
// /* Setters begin */
// public void setUserID(int userID) {
// setColumn(getColumnNameUserID(),userID);
// }
//
// public void setAttribute(String attribute) {
// setColumn(getColumnNameAttribute(),attribute);
// }
//
// public void setValue(String value) {
// setColumn(getColumnNameValue(),value);
// }
//
// }
|
import java.rmi.RemoteException;
import java.sql.SQLException;
import javax.transaction.TransactionManager;
import com.idega.block.staff.data.StaffEntity;
import com.idega.block.staff.data.StaffInfo;
import com.idega.block.staff.data.StaffLocalized;
import com.idega.block.staff.data.StaffMeta;
import com.idega.block.staff.data.StaffMetaData;
import com.idega.block.staff.data.StaffMetaDataBMPBean;
import com.idega.core.user.business.UserBusiness;
import com.idega.core.user.business.UserGroupBusiness;
import com.idega.data.GenericEntity;
import com.idega.transaction.IdegaTransactionManager;
import com.idega.util.IWTimestamp;
|
if ( v6 != null ) {
meta.setValue(v6);
}
meta.insert();
}
t.commit();
} catch (Exception e) {
e.printStackTrace(System.err);
try {
t.rollback();
} catch (Exception e1) {
e1.printStackTrace(System.err);
}
}
}
public static void saveMetaData(int localeID,int userID,String[] attributes,String[] values) {
try {
|
// Path: src/java/com/idega/block/staff/data/StaffEntity.java
// public interface StaffEntity extends com.idega.data.IDOLegacyEntity
// {
// public void delete()throws java.sql.SQLException;
// public java.sql.Date getBeganWork();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setImageID(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffInfo.java
// public interface StaffInfo extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.sql.Date getBeganWork();
// public java.lang.String getEducation();
// public java.lang.String getIDColumnName();
// public int getImageID();
// public java.lang.String getSchool();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setBeganWork(java.sql.Date p0);
// public void setDefaultValues();
// public void setEducation(java.lang.String p0);
// public void setImageID(int p0);
// public void setSchool(java.lang.String p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffLocalized.java
// public interface StaffLocalized extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getArea();
// public java.lang.String getEducation();
// public int getLocaleId();
// public java.lang.String getTitle();
// public void setArea(java.lang.String p0);
// public void setEducation(java.lang.String p0);
// public void setLocaleId(int p0);
// public void setLocaleId(java.lang.Integer p0);
// public void setTitle(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMeta.java
// public interface StaffMeta extends com.idega.block.staff.data.StaffMetaData
// {
// public int getLocaleId();
// public void setLocaleId(int p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaData.java
// public interface StaffMetaData extends com.idega.data.IDOLegacyEntity
// {
// public java.lang.String getAttribute();
// public int getUserID();
// public java.lang.String getValue();
// public void setAttribute(java.lang.String p0);
// public void setUserID(int p0);
// public void setValue(java.lang.String p0);
// }
//
// Path: src/java/com/idega/block/staff/data/StaffMetaDataBMPBean.java
// public class StaffMetaDataBMPBean extends com.idega.data.GenericEntity implements com.idega.block.staff.data.StaffMetaData {
//
// private static String sClassName = StaffMetaData.class.getName();
//
// public StaffMetaDataBMPBean(){
// super();
// }
//
// public StaffMetaDataBMPBean(int id)throws SQLException{
// super(id);
// }
//
//
// public String getEntityName(){
// return "st_staff_meta_data";
// }
//
// public void initializeAttributes(){
// addAttribute(getColumnNameUserID(),"User",true,true,"java.lang.Integer","many-to-one","com.idega.core.user.data.User");
// addAttribute(getColumnNameAttribute(),"Attribute",true,true,"java.lang.String");
// addAttribute(getColumnNameValue(),"Value",true,true,"java.lang.String");
// }
//
//
// public static StaffMetaData getStaticInstance(){
// return (StaffMetaData)GenericEntity.getStaticInstance(sClassName);
// }
//
//
// /* ColumnNames begin */
//
// public static String getColumnNameUserID(){return UserBMPBean.getColumnNameUserID();}
// public static String getColumnNameAttribute(){return "meta_attribute";}
// public static String getColumnNameValue(){return "meta_value";}
//
// /* ColumnNames end */
//
//
// /* Getters begin */
//
// public int getUserID() {
// return getIntColumnValue(getColumnNameUserID());
// }
//
// public String getAttribute() {
// return (String) getColumnValue(getColumnNameAttribute());
// }
//
// public String getValue() {
// return (String) getColumnValue(getColumnNameValue());
// }
//
// /* Getters end */
//
//
// /* Setters begin */
// public void setUserID(int userID) {
// setColumn(getColumnNameUserID(),userID);
// }
//
// public void setAttribute(String attribute) {
// setColumn(getColumnNameAttribute(),attribute);
// }
//
// public void setValue(String value) {
// setColumn(getColumnNameValue(),value);
// }
//
// }
// Path: src/java/com/idega/block/staff/business/StaffBusiness.java
import java.rmi.RemoteException;
import java.sql.SQLException;
import javax.transaction.TransactionManager;
import com.idega.block.staff.data.StaffEntity;
import com.idega.block.staff.data.StaffInfo;
import com.idega.block.staff.data.StaffLocalized;
import com.idega.block.staff.data.StaffMeta;
import com.idega.block.staff.data.StaffMetaData;
import com.idega.block.staff.data.StaffMetaDataBMPBean;
import com.idega.core.user.business.UserBusiness;
import com.idega.core.user.business.UserGroupBusiness;
import com.idega.data.GenericEntity;
import com.idega.transaction.IdegaTransactionManager;
import com.idega.util.IWTimestamp;
if ( v6 != null ) {
meta.setValue(v6);
}
meta.insert();
}
t.commit();
} catch (Exception e) {
e.printStackTrace(System.err);
try {
t.rollback();
} catch (Exception e1) {
e1.printStackTrace(System.err);
}
}
}
public static void saveMetaData(int localeID,int userID,String[] attributes,String[] values) {
try {
|
GenericEntity.getStaticInstance(StaffMeta.class).deleteMultiple(StaffMetaDataBMPBean.getColumnNameUserID(),Integer.toString(userID),com.idega.block.staff.data.StaffMetaBMPBean.getColumnNameLocaleId(),Integer.toString(localeID));
|
idega/com.idega.block.staff
|
src/java/com/idega/block/staff/presentation/item/StaffUserItem.java
|
// Path: src/java/com/idega/block/staff/business/StaffUserBusiness.java
// public interface StaffUserBusiness extends UserBusiness {
//
// public static final String PARAMETER_USER_ID = "st_user_id";
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getGroups
// */
// public Collection getGroups(Group parentGroup)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserEducation
// */
// public String getUserEducation(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserTitle
// */
// public String getUserTitle(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserArea
// */
// public String getUserArea(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getBeganWork
// */
// public Date getBeganWork(User user) throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#storeStaffUser
// */
// public void storeStaffUser(User user, String education, String title,
// String area, Date beganWork, Locale locale)
// throws java.rmi.RemoteException;
//
// }
//
// Path: src/java/com/idega/block/staff/business/StaffUserSession.java
// public interface StaffUserSession extends IBOSession {
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#setUser
// */
// public void setUser(User user) throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#getUser
// */
// public User getUser() throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#setUserID
// */
// public void setUserID(int userID) throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#getUserID
// */
// public int getUserID() throws java.rmi.RemoteException;
//
// }
|
import java.rmi.RemoteException;
import com.idega.block.staff.business.StaffUserBusiness;
import com.idega.block.staff.business.StaffUserSession;
import com.idega.business.IBOLookup;
import com.idega.business.IBOLookupException;
import com.idega.business.IBORuntimeException;
import com.idega.core.accesscontrol.business.NotLoggedOnException;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.idegaweb.IWUserContext;
import com.idega.presentation.Block;
import com.idega.presentation.IWContext;
import com.idega.presentation.PresentationObject;
import com.idega.user.data.User;
|
log(re);
}
User user = null;
try {
user = getSession(iwc).getUser();
}
catch (RemoteException re) {
log(re);
}
if (user != null) {
PresentationObject item = null;
try {
item = getItem(iwc);
}
catch (RemoteException re) {
log(re);
}
if (item != null) {
if (this.styleClass != null) {
item.setStyleClass(this.styleClass);
}
add(item);
}
}
}
private void handleParameters(IWContext iwc) throws RemoteException {
int userID = -1;
|
// Path: src/java/com/idega/block/staff/business/StaffUserBusiness.java
// public interface StaffUserBusiness extends UserBusiness {
//
// public static final String PARAMETER_USER_ID = "st_user_id";
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getGroups
// */
// public Collection getGroups(Group parentGroup)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserEducation
// */
// public String getUserEducation(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserTitle
// */
// public String getUserTitle(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserArea
// */
// public String getUserArea(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getBeganWork
// */
// public Date getBeganWork(User user) throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#storeStaffUser
// */
// public void storeStaffUser(User user, String education, String title,
// String area, Date beganWork, Locale locale)
// throws java.rmi.RemoteException;
//
// }
//
// Path: src/java/com/idega/block/staff/business/StaffUserSession.java
// public interface StaffUserSession extends IBOSession {
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#setUser
// */
// public void setUser(User user) throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#getUser
// */
// public User getUser() throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#setUserID
// */
// public void setUserID(int userID) throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#getUserID
// */
// public int getUserID() throws java.rmi.RemoteException;
//
// }
// Path: src/java/com/idega/block/staff/presentation/item/StaffUserItem.java
import java.rmi.RemoteException;
import com.idega.block.staff.business.StaffUserBusiness;
import com.idega.block.staff.business.StaffUserSession;
import com.idega.business.IBOLookup;
import com.idega.business.IBOLookupException;
import com.idega.business.IBORuntimeException;
import com.idega.core.accesscontrol.business.NotLoggedOnException;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.idegaweb.IWUserContext;
import com.idega.presentation.Block;
import com.idega.presentation.IWContext;
import com.idega.presentation.PresentationObject;
import com.idega.user.data.User;
log(re);
}
User user = null;
try {
user = getSession(iwc).getUser();
}
catch (RemoteException re) {
log(re);
}
if (user != null) {
PresentationObject item = null;
try {
item = getItem(iwc);
}
catch (RemoteException re) {
log(re);
}
if (item != null) {
if (this.styleClass != null) {
item.setStyleClass(this.styleClass);
}
add(item);
}
}
}
private void handleParameters(IWContext iwc) throws RemoteException {
int userID = -1;
|
if (iwc.isParameterSet(StaffUserBusiness.PARAMETER_USER_ID)) {
|
idega/com.idega.block.staff
|
src/java/com/idega/block/staff/presentation/item/StaffUserItem.java
|
// Path: src/java/com/idega/block/staff/business/StaffUserBusiness.java
// public interface StaffUserBusiness extends UserBusiness {
//
// public static final String PARAMETER_USER_ID = "st_user_id";
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getGroups
// */
// public Collection getGroups(Group parentGroup)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserEducation
// */
// public String getUserEducation(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserTitle
// */
// public String getUserTitle(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserArea
// */
// public String getUserArea(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getBeganWork
// */
// public Date getBeganWork(User user) throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#storeStaffUser
// */
// public void storeStaffUser(User user, String education, String title,
// String area, Date beganWork, Locale locale)
// throws java.rmi.RemoteException;
//
// }
//
// Path: src/java/com/idega/block/staff/business/StaffUserSession.java
// public interface StaffUserSession extends IBOSession {
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#setUser
// */
// public void setUser(User user) throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#getUser
// */
// public User getUser() throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#setUserID
// */
// public void setUserID(int userID) throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#getUserID
// */
// public int getUserID() throws java.rmi.RemoteException;
//
// }
|
import java.rmi.RemoteException;
import com.idega.block.staff.business.StaffUserBusiness;
import com.idega.block.staff.business.StaffUserSession;
import com.idega.business.IBOLookup;
import com.idega.business.IBOLookupException;
import com.idega.business.IBORuntimeException;
import com.idega.core.accesscontrol.business.NotLoggedOnException;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.idegaweb.IWUserContext;
import com.idega.presentation.Block;
import com.idega.presentation.IWContext;
import com.idega.presentation.PresentationObject;
import com.idega.user.data.User;
|
userID = Integer.parseInt(iwc.getParameter(StaffUserBusiness.PARAMETER_USER_ID));
}
catch (NumberFormatException e) {
userID = -1;
}
}
else {
try {
userID = iwc.getCurrentUserId();
}
catch (NotLoggedOnException nloe) {
userID = -1;
}
}
if (userID != -1 && userID != getSession(iwc).getUserID()) {
getSession(iwc).setUserID(userID);
getSession(iwc).setUser(getBusiness(iwc).getUser(userID));
}
}
protected StaffUserBusiness getBusiness(IWApplicationContext iwac) {
try {
return (StaffUserBusiness) IBOLookup.getServiceInstance(iwac, StaffUserBusiness.class);
}
catch (IBOLookupException ile) {
throw new IBORuntimeException(ile);
}
}
|
// Path: src/java/com/idega/block/staff/business/StaffUserBusiness.java
// public interface StaffUserBusiness extends UserBusiness {
//
// public static final String PARAMETER_USER_ID = "st_user_id";
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getGroups
// */
// public Collection getGroups(Group parentGroup)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserEducation
// */
// public String getUserEducation(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserTitle
// */
// public String getUserTitle(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getUserArea
// */
// public String getUserArea(User user, Locale locale)
// throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#getBeganWork
// */
// public Date getBeganWork(User user) throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserBusinessBean#storeStaffUser
// */
// public void storeStaffUser(User user, String education, String title,
// String area, Date beganWork, Locale locale)
// throws java.rmi.RemoteException;
//
// }
//
// Path: src/java/com/idega/block/staff/business/StaffUserSession.java
// public interface StaffUserSession extends IBOSession {
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#setUser
// */
// public void setUser(User user) throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#getUser
// */
// public User getUser() throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#setUserID
// */
// public void setUserID(int userID) throws java.rmi.RemoteException;
//
// /**
// * @see com.idega.block.staff.business.StaffUserSessionBean#getUserID
// */
// public int getUserID() throws java.rmi.RemoteException;
//
// }
// Path: src/java/com/idega/block/staff/presentation/item/StaffUserItem.java
import java.rmi.RemoteException;
import com.idega.block.staff.business.StaffUserBusiness;
import com.idega.block.staff.business.StaffUserSession;
import com.idega.business.IBOLookup;
import com.idega.business.IBOLookupException;
import com.idega.business.IBORuntimeException;
import com.idega.core.accesscontrol.business.NotLoggedOnException;
import com.idega.idegaweb.IWApplicationContext;
import com.idega.idegaweb.IWBundle;
import com.idega.idegaweb.IWResourceBundle;
import com.idega.idegaweb.IWUserContext;
import com.idega.presentation.Block;
import com.idega.presentation.IWContext;
import com.idega.presentation.PresentationObject;
import com.idega.user.data.User;
userID = Integer.parseInt(iwc.getParameter(StaffUserBusiness.PARAMETER_USER_ID));
}
catch (NumberFormatException e) {
userID = -1;
}
}
else {
try {
userID = iwc.getCurrentUserId();
}
catch (NotLoggedOnException nloe) {
userID = -1;
}
}
if (userID != -1 && userID != getSession(iwc).getUserID()) {
getSession(iwc).setUserID(userID);
getSession(iwc).setUser(getBusiness(iwc).getUser(userID));
}
}
protected StaffUserBusiness getBusiness(IWApplicationContext iwac) {
try {
return (StaffUserBusiness) IBOLookup.getServiceInstance(iwac, StaffUserBusiness.class);
}
catch (IBOLookupException ile) {
throw new IBORuntimeException(ile);
}
}
|
protected StaffUserSession getSession(IWUserContext iwuc) {
|
uvagfx/hipi
|
core/src/main/java/org/hipi/opencv/OpenCVUtils.java
|
// Path: core/src/main/java/org/hipi/image/PixelArray.java
// public abstract class PixelArray {
//
// public static final int TYPE_BYTE = 0;
// public static final int TYPE_USHORT = 1;
// public static final int TYPE_SHORT = 2;
// public static final int TYPE_INT = 3;
// public static final int TYPE_FLOAT = 4;
// public static final int TYPE_DOUBLE = 5;
// public static final int TYPE_UNDEFINED = 32;
//
// private static final int dataTypeSize[] = {1,2,2,4,4,8};
//
// /**
// * Integer value indicating underlying scalar value data type.
// */
// protected int dataType;
//
// /**
// * Size, in bytes, of a single scalar value in pixel array.
// */
// protected int size;
//
// /**
// * Static function that reports size, in bytes, of a single scalar value for different types
// * of pixel arrays.
// *
// * @param type scalar value type
// *
// * @return size, in bytes, of single scalar value for specified type
// */
// public static int getDataTypeSize(int type) {
// if (type < TYPE_BYTE || type > TYPE_DOUBLE) {
// throw new IllegalArgumentException("Unknown data type "+type);
// }
// return dataTypeSize[type];
// }
//
// public PixelArray() {
// this.dataType = TYPE_UNDEFINED;
// this.size = 0;
// }
//
// protected PixelArray(int dataType, int size) {
// this.dataType = dataType;
// this.size = size;
// }
//
// public int getDataType() {
// return dataType;
// }
//
// public int getSize() {
// return size;
// }
//
// public abstract void setSize(int size) throws IllegalArgumentException;
//
// public abstract byte[] getByteArray();
//
// public abstract void setFromByteArray(byte[] bytes) throws IllegalArgumentException;
//
// public abstract int getElem(int i);
//
// public abstract int getElemNonLinSRGB(int i);
//
// public abstract void setElem(int i, int val);
//
// public abstract void setElemNonLinSRGB(int i, int val);
//
// public float getElemFloat(int i) {
// return (float)getElem(i);
// }
//
// public void setElemFloat(int i, float val) {
// setElem(i,(int)val);
// }
//
// public double getElemDouble(int i) {
// return (double)getElem(i);
// }
//
// public void setElemDouble(int i, double val) {
// setElem(i,(int)val);
// }
//
// }
|
import org.hipi.image.PixelArray;
import org.hipi.image.RasterImage;
import org.hipi.util.ByteUtils;
import org.apache.hadoop.mapreduce.RecordReader;
import org.bytedeco.javacpp.opencv_core;
import org.bytedeco.javacpp.opencv_core.Mat;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
|
package org.hipi.opencv;
/**
* Various static helper methods which facilitate conversion between HIPI and OpenCV image
* representations.
*/
public class OpenCVUtils {
private static int[][] openCVTypeLUT = new int[][]
{{opencv_core.CV_8UC1, opencv_core.CV_8UC2, opencv_core.CV_8UC3, opencv_core.CV_8UC4},
{opencv_core.CV_16UC1, opencv_core.CV_16UC2, opencv_core.CV_16UC3, opencv_core.CV_16UC4},
{opencv_core.CV_16SC1, opencv_core.CV_16SC2, opencv_core.CV_16SC3, opencv_core.CV_16SC4},
{opencv_core.CV_32SC1, opencv_core.CV_32SC2, opencv_core.CV_32SC3, opencv_core.CV_32SC4},
{opencv_core.CV_32FC1, opencv_core.CV_32FC2, opencv_core.CV_32FC3, opencv_core.CV_32FC4},
{opencv_core.CV_64FC1, opencv_core.CV_64FC2, opencv_core.CV_64FC3, opencv_core.CV_64FC4}};
/**
* Returns the OpenCV data type which is associated with a particular {@link PixelArray} data type
* and number of bands.
*
* @return integer representation of OpenCV data type
*/
public static int generateOpenCVType(int pixelArrayDataType, int numBands) {
int depthIndex = -1;
switch(pixelArrayDataType) {
|
// Path: core/src/main/java/org/hipi/image/PixelArray.java
// public abstract class PixelArray {
//
// public static final int TYPE_BYTE = 0;
// public static final int TYPE_USHORT = 1;
// public static final int TYPE_SHORT = 2;
// public static final int TYPE_INT = 3;
// public static final int TYPE_FLOAT = 4;
// public static final int TYPE_DOUBLE = 5;
// public static final int TYPE_UNDEFINED = 32;
//
// private static final int dataTypeSize[] = {1,2,2,4,4,8};
//
// /**
// * Integer value indicating underlying scalar value data type.
// */
// protected int dataType;
//
// /**
// * Size, in bytes, of a single scalar value in pixel array.
// */
// protected int size;
//
// /**
// * Static function that reports size, in bytes, of a single scalar value for different types
// * of pixel arrays.
// *
// * @param type scalar value type
// *
// * @return size, in bytes, of single scalar value for specified type
// */
// public static int getDataTypeSize(int type) {
// if (type < TYPE_BYTE || type > TYPE_DOUBLE) {
// throw new IllegalArgumentException("Unknown data type "+type);
// }
// return dataTypeSize[type];
// }
//
// public PixelArray() {
// this.dataType = TYPE_UNDEFINED;
// this.size = 0;
// }
//
// protected PixelArray(int dataType, int size) {
// this.dataType = dataType;
// this.size = size;
// }
//
// public int getDataType() {
// return dataType;
// }
//
// public int getSize() {
// return size;
// }
//
// public abstract void setSize(int size) throws IllegalArgumentException;
//
// public abstract byte[] getByteArray();
//
// public abstract void setFromByteArray(byte[] bytes) throws IllegalArgumentException;
//
// public abstract int getElem(int i);
//
// public abstract int getElemNonLinSRGB(int i);
//
// public abstract void setElem(int i, int val);
//
// public abstract void setElemNonLinSRGB(int i, int val);
//
// public float getElemFloat(int i) {
// return (float)getElem(i);
// }
//
// public void setElemFloat(int i, float val) {
// setElem(i,(int)val);
// }
//
// public double getElemDouble(int i) {
// return (double)getElem(i);
// }
//
// public void setElemDouble(int i, double val) {
// setElem(i,(int)val);
// }
//
// }
// Path: core/src/main/java/org/hipi/opencv/OpenCVUtils.java
import org.hipi.image.PixelArray;
import org.hipi.image.RasterImage;
import org.hipi.util.ByteUtils;
import org.apache.hadoop.mapreduce.RecordReader;
import org.bytedeco.javacpp.opencv_core;
import org.bytedeco.javacpp.opencv_core.Mat;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
package org.hipi.opencv;
/**
* Various static helper methods which facilitate conversion between HIPI and OpenCV image
* representations.
*/
public class OpenCVUtils {
private static int[][] openCVTypeLUT = new int[][]
{{opencv_core.CV_8UC1, opencv_core.CV_8UC2, opencv_core.CV_8UC3, opencv_core.CV_8UC4},
{opencv_core.CV_16UC1, opencv_core.CV_16UC2, opencv_core.CV_16UC3, opencv_core.CV_16UC4},
{opencv_core.CV_16SC1, opencv_core.CV_16SC2, opencv_core.CV_16SC3, opencv_core.CV_16SC4},
{opencv_core.CV_32SC1, opencv_core.CV_32SC2, opencv_core.CV_32SC3, opencv_core.CV_32SC4},
{opencv_core.CV_32FC1, opencv_core.CV_32FC2, opencv_core.CV_32FC3, opencv_core.CV_32FC4},
{opencv_core.CV_64FC1, opencv_core.CV_64FC2, opencv_core.CV_64FC3, opencv_core.CV_64FC4}};
/**
* Returns the OpenCV data type which is associated with a particular {@link PixelArray} data type
* and number of bands.
*
* @return integer representation of OpenCV data type
*/
public static int generateOpenCVType(int pixelArrayDataType, int numBands) {
int depthIndex = -1;
switch(pixelArrayDataType) {
|
case PixelArray.TYPE_BYTE:
|
uvagfx/hipi
|
core/src/test/java/org/hipi/test/OpenCVMatWritableTestCase.java
|
// Path: core/src/main/java/org/hipi/opencv/OpenCVMatWritable.java
// public class OpenCVMatWritable implements Writable {
//
// private Mat mat = null;
//
// public OpenCVMatWritable() {
// mat = new Mat();
// assert mat != null;
// mat.dims(2);
// assert (mat.dims() == 2); // handle only 1- or 2-D arrays (sanity check)
// }
//
// public OpenCVMatWritable(Mat mat) {
// setMat(mat);
// }
//
// public void setMat(Mat mat) throws IllegalArgumentException {
// if (mat == null) {
// throw new IllegalArgumentException("Must provide valid non-null Mat object.");
// }
// int dims = mat.dims();
// if (!(dims == 1 || dims == 2)) {
// throw new IllegalArgumentException("Currently supports only 1D or 2D arrays. "
// + "Input mat dims: " + dims);
// }
//
// Mat matCopy = new Mat(mat.rows(), mat.cols(), mat.type());
// mat.copyTo(matCopy);
// this.mat = matCopy;
// }
//
// public Mat getMat() {
// Mat matCopy = new Mat(mat.rows(), mat.cols(), mat.type());
// mat.copyTo(matCopy);
// return matCopy;
// }
//
// public void write(DataOutput out) throws IOException {
//
// assert mat != null;
// int dims = mat.dims();
// assert (dims == 1 || dims == 2); // handle only 1- or 2-D arrays
//
// int type = mat.type();
// out.writeInt(type);
// out.writeInt(mat.rows());
// out.writeInt(mat.cols());
//
// int elms = (int)(mat.total() * mat.channels());
// if (elms > 0) {
// int depth = opencv_core.CV_MAT_DEPTH(type);
// switch (depth) {
// case opencv_core.CV_8U:
// case opencv_core.CV_8S:
// byte [] data = new byte[elms];
// ((ByteBuffer)mat.createBuffer()).get(data);
// out.write(data);
// break;
// case opencv_core.CV_16U:
// case opencv_core.CV_16S:
// short [] shortData = new short[elms];
// ((ShortBuffer)mat.createBuffer()).get(shortData);
// out.write(ByteUtils.shortArrayToByteArray(shortData));
// break;
// case opencv_core.CV_32S:
// int [] intData = new int[elms];
// ((IntBuffer)mat.createBuffer()).get(intData);
// out.write(ByteUtils.intArrayToByteArray(intData));
// break;
// case opencv_core.CV_32F:
// float [] floatData = new float[elms];
// ((FloatBuffer)mat.createBuffer()).get(floatData);
// out.write(ByteUtils.floatArrayToByteArray(floatData));
// break;
// case opencv_core.CV_64F:
// double [] doubleData = new double[elms];
// ((DoubleBuffer)mat.createBuffer()).get(doubleData);
// out.write(ByteUtils.doubleArrayToByteArray(doubleData));
// break;
// default:
// throw new IOException("Unsupported matrix depth [" + depth + "].");
// }
// }
//
// }
//
// public void readFields(DataInput in) throws IOException {
// int type = in.readInt();
// int depth = opencv_core.CV_MAT_DEPTH(type);
// int rows = in.readInt();
// int cols = in.readInt();
//
// mat = new Mat(rows, cols, type);
//
// int elms = (int)(mat.total() * mat.channels());
//
// switch (depth) {
// case opencv_core.CV_8U:
// case opencv_core.CV_8S:
// byte[] data = new byte[elms];
// in.readFully(data);
// ((ByteBuffer)mat.createBuffer()).put(data);
// break;
// case opencv_core.CV_16U:
// case opencv_core.CV_16S:
// byte[] shortDataAsBytes = new byte[elms * 2]; // 2 bytes per short
// in.readFully(shortDataAsBytes);
// ((ShortBuffer)mat.createBuffer()).put(ByteUtils.byteArrayToShortArray(shortDataAsBytes));
// break;
// case opencv_core.CV_32S:
// byte[] intDataAsBytes = new byte[elms * 4]; // 4 bytes per int
// in.readFully(intDataAsBytes);
// ((IntBuffer)mat.createBuffer()).put(ByteUtils.byteArrayToIntArray(intDataAsBytes));
// break;
// case opencv_core.CV_32F:
// byte[] floatDataAsBytes = new byte[elms * 4]; // 4 bytes per float
// in.readFully(floatDataAsBytes);
// ((FloatBuffer)mat.createBuffer()).put(ByteUtils.byteArrayToFloatArray(floatDataAsBytes));
// break;
// case opencv_core.CV_64F:
// byte[] doubleDataAsBytes = new byte[elms * 8]; // 8 bytes per double
// in.readFully(doubleDataAsBytes);
// ((DoubleBuffer)mat.createBuffer()).put(ByteUtils.byteArrayToDoubleArray(doubleDataAsBytes));
// break;
// default:
// throw new IOException("Unsupported matrix depth [" + depth + "].");
// }
// }
//
//
// }
|
import static org.junit.Assert.*;
import org.hipi.opencv.OpenCVMatWritable;
import org.junit.Assert;
import org.junit.Test;
import org.bytedeco.javacpp.opencv_core;
import org.bytedeco.javacpp.opencv_core.Mat;
import org.bytedeco.javacpp.opencv_core.Size;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
|
package org.hipi.test;
public class OpenCVMatWritableTestCase {
private final double delta = 0.01;
@Test
public void testDefaultConstructorMatDimensions() {
|
// Path: core/src/main/java/org/hipi/opencv/OpenCVMatWritable.java
// public class OpenCVMatWritable implements Writable {
//
// private Mat mat = null;
//
// public OpenCVMatWritable() {
// mat = new Mat();
// assert mat != null;
// mat.dims(2);
// assert (mat.dims() == 2); // handle only 1- or 2-D arrays (sanity check)
// }
//
// public OpenCVMatWritable(Mat mat) {
// setMat(mat);
// }
//
// public void setMat(Mat mat) throws IllegalArgumentException {
// if (mat == null) {
// throw new IllegalArgumentException("Must provide valid non-null Mat object.");
// }
// int dims = mat.dims();
// if (!(dims == 1 || dims == 2)) {
// throw new IllegalArgumentException("Currently supports only 1D or 2D arrays. "
// + "Input mat dims: " + dims);
// }
//
// Mat matCopy = new Mat(mat.rows(), mat.cols(), mat.type());
// mat.copyTo(matCopy);
// this.mat = matCopy;
// }
//
// public Mat getMat() {
// Mat matCopy = new Mat(mat.rows(), mat.cols(), mat.type());
// mat.copyTo(matCopy);
// return matCopy;
// }
//
// public void write(DataOutput out) throws IOException {
//
// assert mat != null;
// int dims = mat.dims();
// assert (dims == 1 || dims == 2); // handle only 1- or 2-D arrays
//
// int type = mat.type();
// out.writeInt(type);
// out.writeInt(mat.rows());
// out.writeInt(mat.cols());
//
// int elms = (int)(mat.total() * mat.channels());
// if (elms > 0) {
// int depth = opencv_core.CV_MAT_DEPTH(type);
// switch (depth) {
// case opencv_core.CV_8U:
// case opencv_core.CV_8S:
// byte [] data = new byte[elms];
// ((ByteBuffer)mat.createBuffer()).get(data);
// out.write(data);
// break;
// case opencv_core.CV_16U:
// case opencv_core.CV_16S:
// short [] shortData = new short[elms];
// ((ShortBuffer)mat.createBuffer()).get(shortData);
// out.write(ByteUtils.shortArrayToByteArray(shortData));
// break;
// case opencv_core.CV_32S:
// int [] intData = new int[elms];
// ((IntBuffer)mat.createBuffer()).get(intData);
// out.write(ByteUtils.intArrayToByteArray(intData));
// break;
// case opencv_core.CV_32F:
// float [] floatData = new float[elms];
// ((FloatBuffer)mat.createBuffer()).get(floatData);
// out.write(ByteUtils.floatArrayToByteArray(floatData));
// break;
// case opencv_core.CV_64F:
// double [] doubleData = new double[elms];
// ((DoubleBuffer)mat.createBuffer()).get(doubleData);
// out.write(ByteUtils.doubleArrayToByteArray(doubleData));
// break;
// default:
// throw new IOException("Unsupported matrix depth [" + depth + "].");
// }
// }
//
// }
//
// public void readFields(DataInput in) throws IOException {
// int type = in.readInt();
// int depth = opencv_core.CV_MAT_DEPTH(type);
// int rows = in.readInt();
// int cols = in.readInt();
//
// mat = new Mat(rows, cols, type);
//
// int elms = (int)(mat.total() * mat.channels());
//
// switch (depth) {
// case opencv_core.CV_8U:
// case opencv_core.CV_8S:
// byte[] data = new byte[elms];
// in.readFully(data);
// ((ByteBuffer)mat.createBuffer()).put(data);
// break;
// case opencv_core.CV_16U:
// case opencv_core.CV_16S:
// byte[] shortDataAsBytes = new byte[elms * 2]; // 2 bytes per short
// in.readFully(shortDataAsBytes);
// ((ShortBuffer)mat.createBuffer()).put(ByteUtils.byteArrayToShortArray(shortDataAsBytes));
// break;
// case opencv_core.CV_32S:
// byte[] intDataAsBytes = new byte[elms * 4]; // 4 bytes per int
// in.readFully(intDataAsBytes);
// ((IntBuffer)mat.createBuffer()).put(ByteUtils.byteArrayToIntArray(intDataAsBytes));
// break;
// case opencv_core.CV_32F:
// byte[] floatDataAsBytes = new byte[elms * 4]; // 4 bytes per float
// in.readFully(floatDataAsBytes);
// ((FloatBuffer)mat.createBuffer()).put(ByteUtils.byteArrayToFloatArray(floatDataAsBytes));
// break;
// case opencv_core.CV_64F:
// byte[] doubleDataAsBytes = new byte[elms * 8]; // 8 bytes per double
// in.readFully(doubleDataAsBytes);
// ((DoubleBuffer)mat.createBuffer()).put(ByteUtils.byteArrayToDoubleArray(doubleDataAsBytes));
// break;
// default:
// throw new IOException("Unsupported matrix depth [" + depth + "].");
// }
// }
//
//
// }
// Path: core/src/test/java/org/hipi/test/OpenCVMatWritableTestCase.java
import static org.junit.Assert.*;
import org.hipi.opencv.OpenCVMatWritable;
import org.junit.Assert;
import org.junit.Test;
import org.bytedeco.javacpp.opencv_core;
import org.bytedeco.javacpp.opencv_core.Mat;
import org.bytedeco.javacpp.opencv_core.Size;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
package org.hipi.test;
public class OpenCVMatWritableTestCase {
private final double delta = 0.01;
@Test
public void testDefaultConstructorMatDimensions() {
|
OpenCVMatWritable openCvMatWritable = new OpenCVMatWritable();
|
uvagfx/hipi
|
tools/hibImport/src/main/java/org/hipi/tools/HibImport.java
|
// Path: core/src/main/java/org/hipi/image/HipiImageHeader.java
// public enum HipiImageFormat {
// UNDEFINED(0x0), JPEG(0x1), PNG(0x2), PPM(0x3);
//
// private int format;
//
// /**
// * Creates an ImageFormat from an int.
// *
// * @param format Integer representation of ImageFormat.
// */
// HipiImageFormat(int format) {
// this.format = format;
// }
//
// /**
// * Creates an ImageFormat from an int.
// *
// * @param format Integer representation of ImageFormat.
// *
// * @return Associated ImageFormat.
// *
// * @throws IllegalArgumentException if the parameter value does not correspond to a valid
// * HipiImageFormat.
// */
// public static HipiImageFormat fromInteger(int format) throws IllegalArgumentException {
// for (HipiImageFormat fmt : values()) {
// if (fmt.format == format) {
// return fmt;
// }
// }
// throw new IllegalArgumentException(String.format("There is no HipiImageFormat enum value " +
// "associated with integer [%d]", format));
// }
//
// /**
// * @return Integer representation of ImageFormat.
// */
// public int toInteger() {
// return format;
// }
//
// /**
// * Default HipiImageFormat.
// *
// * @return HipiImageFormat.UNDEFINED
// */
// public static HipiImageFormat getDefault() {
// return UNDEFINED;
// }
//
// } // public enum ImageFormat
|
import org.hipi.imagebundle.HipiImageBundle;
import org.hipi.image.HipiImageHeader.HipiImageFormat;
import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.Parser;
import org.apache.commons.cli.ParseException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FSDataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Arrays;
import java.util.List;
|
}
System.out.println("Input image directory: " + imageDir);
System.out.println("Input FS: " + (hdfsInput ? "HDFS" : "local FS"));
System.out.println("Output HIB: " + outputHib);
System.out.println("Overwrite HIB if it exists: " + (overwrite ? "true" : "false"));
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
if (hdfsInput) {
FileStatus[] files = fs.listStatus(new Path(imageDir));
if (files == null) {
System.err.println(String.format("Did not find any files in the HDFS directory [%s]", imageDir));
System.exit(0);
}
Arrays.sort(files);
HipiImageBundle hib = new HipiImageBundle(new Path(outputHib), conf);
hib.openForWrite(overwrite);
for (FileStatus file : files) {
FSDataInputStream fdis = fs.open(file.getPath());
String source = file.getPath().toString();
HashMap<String, String> metaData = new HashMap<String,String>();
metaData.put("source", source);
String fileName = file.getPath().getName().toLowerCase();
String suffix = fileName.substring(fileName.lastIndexOf('.'));
if (suffix.compareTo(".jpg") == 0 || suffix.compareTo(".jpeg") == 0) {
|
// Path: core/src/main/java/org/hipi/image/HipiImageHeader.java
// public enum HipiImageFormat {
// UNDEFINED(0x0), JPEG(0x1), PNG(0x2), PPM(0x3);
//
// private int format;
//
// /**
// * Creates an ImageFormat from an int.
// *
// * @param format Integer representation of ImageFormat.
// */
// HipiImageFormat(int format) {
// this.format = format;
// }
//
// /**
// * Creates an ImageFormat from an int.
// *
// * @param format Integer representation of ImageFormat.
// *
// * @return Associated ImageFormat.
// *
// * @throws IllegalArgumentException if the parameter value does not correspond to a valid
// * HipiImageFormat.
// */
// public static HipiImageFormat fromInteger(int format) throws IllegalArgumentException {
// for (HipiImageFormat fmt : values()) {
// if (fmt.format == format) {
// return fmt;
// }
// }
// throw new IllegalArgumentException(String.format("There is no HipiImageFormat enum value " +
// "associated with integer [%d]", format));
// }
//
// /**
// * @return Integer representation of ImageFormat.
// */
// public int toInteger() {
// return format;
// }
//
// /**
// * Default HipiImageFormat.
// *
// * @return HipiImageFormat.UNDEFINED
// */
// public static HipiImageFormat getDefault() {
// return UNDEFINED;
// }
//
// } // public enum ImageFormat
// Path: tools/hibImport/src/main/java/org/hipi/tools/HibImport.java
import org.hipi.imagebundle.HipiImageBundle;
import org.hipi.image.HipiImageHeader.HipiImageFormat;
import org.apache.commons.cli.BasicParser;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.Parser;
import org.apache.commons.cli.ParseException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FSDataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Arrays;
import java.util.List;
}
System.out.println("Input image directory: " + imageDir);
System.out.println("Input FS: " + (hdfsInput ? "HDFS" : "local FS"));
System.out.println("Output HIB: " + outputHib);
System.out.println("Overwrite HIB if it exists: " + (overwrite ? "true" : "false"));
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(conf);
if (hdfsInput) {
FileStatus[] files = fs.listStatus(new Path(imageDir));
if (files == null) {
System.err.println(String.format("Did not find any files in the HDFS directory [%s]", imageDir));
System.exit(0);
}
Arrays.sort(files);
HipiImageBundle hib = new HipiImageBundle(new Path(outputHib), conf);
hib.openForWrite(overwrite);
for (FileStatus file : files) {
FSDataInputStream fdis = fs.open(file.getPath());
String source = file.getPath().toString();
HashMap<String, String> metaData = new HashMap<String,String>();
metaData.put("source", source);
String fileName = file.getPath().getName().toLowerCase();
String suffix = fileName.substring(fileName.lastIndexOf('.'));
if (suffix.compareTo(".jpg") == 0 || suffix.compareTo(".jpeg") == 0) {
|
hib.addImage(fdis, HipiImageFormat.JPEG, metaData);
|
google/devtools-driver
|
third_party/ios_driver/org/uiautomation/ios/wkrdp/events/EventHistory.java
|
// Path: third_party/ios_driver/org/uiautomation/ios/wkrdp/model/NodeId.java
// public final class NodeId {
// private final int id;
//
// public NodeId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return id;
// }
//
// @Override
// public String toString() {
// return "" + id;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + id;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// NodeId other = (NodeId) obj;
// if (id != other.id) {
// return false;
// }
// return true;
// }
//
// public boolean exist() {
// return id > 0;
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Logger;
import org.uiautomation.ios.wkrdp.model.NodeId;
|
/*
* Copyright 2012-2013 eBay Software Foundation and ios-driver committers
*
* Licensed 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.uiautomation.ios.wkrdp.events;
public class EventHistory {
private static final Logger log = Logger.getLogger(EventHistory.class.getName());
private static final long MAX_AGE = 10 * 1000;
private final List<Event> events = new CopyOnWriteArrayList<>();
public EventHistory() {}
public void add(Event e) {
if (events.size() >= 50) {
removeOldEvents();
}
events.add(e);
}
public void removeEvent(Event e) {
events.remove(e);
}
private void removeOldEvents() {
int removed = 0;
for (Event e : events) {
if (e.getAge() > MAX_AGE) {
if (events.remove(e)) {
removed++;
}
}
}
if (removed == 0) {
log.warning("events history is growing too fast.");
}
}
|
// Path: third_party/ios_driver/org/uiautomation/ios/wkrdp/model/NodeId.java
// public final class NodeId {
// private final int id;
//
// public NodeId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return id;
// }
//
// @Override
// public String toString() {
// return "" + id;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + id;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// NodeId other = (NodeId) obj;
// if (id != other.id) {
// return false;
// }
// return true;
// }
//
// public boolean exist() {
// return id > 0;
// }
// }
// Path: third_party/ios_driver/org/uiautomation/ios/wkrdp/events/EventHistory.java
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Logger;
import org.uiautomation.ios.wkrdp.model.NodeId;
/*
* Copyright 2012-2013 eBay Software Foundation and ios-driver committers
*
* Licensed 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.uiautomation.ios.wkrdp.events;
public class EventHistory {
private static final Logger log = Logger.getLogger(EventHistory.class.getName());
private static final long MAX_AGE = 10 * 1000;
private final List<Event> events = new CopyOnWriteArrayList<>();
public EventHistory() {}
public void add(Event e) {
if (events.size() >= 50) {
removeOldEvents();
}
events.add(e);
}
public void removeEvent(Event e) {
events.remove(e);
}
private void removeOldEvents() {
int removed = 0;
for (Event e : events) {
if (e.getAge() > MAX_AGE) {
if (events.remove(e)) {
removed++;
}
}
}
if (removed == 0) {
log.warning("events history is growing too fast.");
}
}
|
public List<ChildIframeInserted> getInsertedFrames(NodeId parent) {
|
google/devtools-driver
|
third_party/ios_driver/org/uiautomation/ios/wkrdp/events/NodeEvent.java
|
// Path: third_party/ios_driver/org/uiautomation/ios/wkrdp/model/NodeId.java
// public final class NodeId {
// private final int id;
//
// public NodeId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return id;
// }
//
// @Override
// public String toString() {
// return "" + id;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + id;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// NodeId other = (NodeId) obj;
// if (id != other.id) {
// return false;
// }
// return true;
// }
//
// public boolean exist() {
// return id > 0;
// }
// }
|
import java.util.logging.Logger;
import org.json.JSONException;
import org.json.JSONObject;
import org.uiautomation.ios.wkrdp.model.NodeId;
|
/*
* Copyright 2012-2013 eBay Software Foundation and ios-driver committers
*
* Licensed 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.uiautomation.ios.wkrdp.events;
abstract class NodeEvent extends Event {
private static final Logger log = Logger.getLogger(ChildNodeRemoved.class.getName());
|
// Path: third_party/ios_driver/org/uiautomation/ios/wkrdp/model/NodeId.java
// public final class NodeId {
// private final int id;
//
// public NodeId(int id) {
// this.id = id;
// }
//
// public int getId() {
// return id;
// }
//
// @Override
// public String toString() {
// return "" + id;
// }
//
// @Override
// public int hashCode() {
// final int prime = 31;
// int result = 1;
// result = prime * result + id;
// return result;
// }
//
// @Override
// public boolean equals(Object obj) {
// if (this == obj) {
// return true;
// }
// if (obj == null) {
// return false;
// }
// if (getClass() != obj.getClass()) {
// return false;
// }
// NodeId other = (NodeId) obj;
// if (id != other.id) {
// return false;
// }
// return true;
// }
//
// public boolean exist() {
// return id > 0;
// }
// }
// Path: third_party/ios_driver/org/uiautomation/ios/wkrdp/events/NodeEvent.java
import java.util.logging.Logger;
import org.json.JSONException;
import org.json.JSONObject;
import org.uiautomation.ios.wkrdp.model.NodeId;
/*
* Copyright 2012-2013 eBay Software Foundation and ios-driver committers
*
* Licensed 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.uiautomation.ios.wkrdp.events;
abstract class NodeEvent extends Event {
private static final Logger log = Logger.getLogger(ChildNodeRemoved.class.getName());
|
private final NodeId node;
|
florent37/OCiney
|
app/src/main/java/com/bdc/ociney/adapter/TheaterHorairesPagerAdapter.java
|
// Path: app/src/main/java/com/bdc/ociney/fragment/FragmentTheaderDetailMoviePageHoraires.java
// public class FragmentTheaderDetailMoviePageHoraires extends Fragment {
//
// public static final String JOUR = "jour";
// public static final String HORAIRES = "horaires";
// String jour;
// List<Horaires> horaires;
// View view;
// TextView date;
// ViewGroup listeSeances;
//
// public static FragmentTheaderDetailMoviePageHoraires newInstance(String jour, List<Horaires> horaires) {
// FragmentTheaderDetailMoviePageHoraires fragment = new FragmentTheaderDetailMoviePageHoraires();
// Bundle args = new Bundle();
// args.putString(JOUR, jour);
//
// Gson gSon = new Gson();
// args.putString(HORAIRES, gSon.toJson(horaires));
//
// fragment.setArguments(args);
//
// return fragment;
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// super.onCreateView(inflater, container, savedInstanceState);
//
// Bundle bundle = getArguments();
// this.jour = bundle.getString(JOUR);
// Gson gSon = new Gson();
// this.horaires = gSon.fromJson(bundle.getString(HORAIRES), new TypeToken<List<Horaires>>() {
// }.getType());
//
//
// view = inflater.inflate(R.layout.fragment_theater_detail_movie_content_page_horaires, null);
//
// charger();
// remplir();
// ajouterListener();
//
// return view;
// }
//
// private void charger() {
// date = (TextView) view.findViewById(R.id.date);
// listeSeances = (ViewGroup) view.findViewById(R.id.liste_seances);
// }
//
// private void remplir() {
// date.setText(jour);
// CellTheater.chargerHoraires(listeSeances, horaires, false);
// }
//
// private void ajouterListener() {
//
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Theater/Horaires.java
// public class Horaires {
// boolean avantPremier = false;
// String date;
// String formatEcran;
// String display; //affichage complet
// List<String> seances = new ArrayList<String>();
// String version;
//
// public boolean isAvantPremier() {
// return avantPremier;
// }
//
// public void setAvantPremier(boolean avantPremier) {
// this.avantPremier = avantPremier;
// }
//
// public String getDate() {
// try {
// String[] d = date.split("-");
// return d[2] + "/" + d[1] + "/" + d[0];
// } catch (Exception e) {
// return date;
// }
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public String getFormatEcran() {
// return formatEcran;
// }
//
// public void setFormatEcran(String formatEcran) {
// this.formatEcran = formatEcran;
// }
//
// public String getDisplay() {
// return display;
// }
//
// public void setDisplay(String display) {
// this.display = display;
// }
//
// public List<String> getSeances() {
// return seances;
// }
//
// public void setSeances(List<String> seances) {
// this.seances = seances;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public boolean isToday() {
// String dateFormatted = getDate();
//
// Date now = new Date();
// SimpleDateFormat formater = new SimpleDateFormat("dd/MM/yyyy");
// String nowFormatted = formater.format(now);
//
// Log.d("DATE", dateFormatted + " " + nowFormatted);
//
// return dateFormatted.equals(nowFormatted);
// }
//
// public boolean isMoreThanToday() {
// try {
// String dateFormatted = getDate();
//
// Date now = new Date();
// now.setHours(0);
// now.setSeconds(0);
// now.setMinutes(0);
//
// SimpleDateFormat formater = new SimpleDateFormat("E dd MMMMM yyyy", Locale.FRANCE);
// Date date = formater.parse(dateFormatted);
//
// date.setHours(13);
//
// return date.equals(now) || date.after(now);
// } catch (Exception e) {
// e.printStackTrace();
// return false;
// }
// }
//
// @Override
// public String toString() {
// return "Horraires{" +
// ", date='" + date + '\'' +
// ", seances=" + seances +
// '}';
// }
// }
|
import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import com.bdc.ociney.fragment.FragmentTheaderDetailMoviePageHoraires;
import com.bdc.ociney.modele.Theater.Horaires;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
|
package com.bdc.ociney.adapter;
/**
* Created by florentchampigny on 01/05/2014.
*/
public class TheaterHorairesPagerAdapter extends FragmentStatePagerAdapter {
Activity activity;
|
// Path: app/src/main/java/com/bdc/ociney/fragment/FragmentTheaderDetailMoviePageHoraires.java
// public class FragmentTheaderDetailMoviePageHoraires extends Fragment {
//
// public static final String JOUR = "jour";
// public static final String HORAIRES = "horaires";
// String jour;
// List<Horaires> horaires;
// View view;
// TextView date;
// ViewGroup listeSeances;
//
// public static FragmentTheaderDetailMoviePageHoraires newInstance(String jour, List<Horaires> horaires) {
// FragmentTheaderDetailMoviePageHoraires fragment = new FragmentTheaderDetailMoviePageHoraires();
// Bundle args = new Bundle();
// args.putString(JOUR, jour);
//
// Gson gSon = new Gson();
// args.putString(HORAIRES, gSon.toJson(horaires));
//
// fragment.setArguments(args);
//
// return fragment;
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// super.onCreateView(inflater, container, savedInstanceState);
//
// Bundle bundle = getArguments();
// this.jour = bundle.getString(JOUR);
// Gson gSon = new Gson();
// this.horaires = gSon.fromJson(bundle.getString(HORAIRES), new TypeToken<List<Horaires>>() {
// }.getType());
//
//
// view = inflater.inflate(R.layout.fragment_theater_detail_movie_content_page_horaires, null);
//
// charger();
// remplir();
// ajouterListener();
//
// return view;
// }
//
// private void charger() {
// date = (TextView) view.findViewById(R.id.date);
// listeSeances = (ViewGroup) view.findViewById(R.id.liste_seances);
// }
//
// private void remplir() {
// date.setText(jour);
// CellTheater.chargerHoraires(listeSeances, horaires, false);
// }
//
// private void ajouterListener() {
//
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Theater/Horaires.java
// public class Horaires {
// boolean avantPremier = false;
// String date;
// String formatEcran;
// String display; //affichage complet
// List<String> seances = new ArrayList<String>();
// String version;
//
// public boolean isAvantPremier() {
// return avantPremier;
// }
//
// public void setAvantPremier(boolean avantPremier) {
// this.avantPremier = avantPremier;
// }
//
// public String getDate() {
// try {
// String[] d = date.split("-");
// return d[2] + "/" + d[1] + "/" + d[0];
// } catch (Exception e) {
// return date;
// }
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public String getFormatEcran() {
// return formatEcran;
// }
//
// public void setFormatEcran(String formatEcran) {
// this.formatEcran = formatEcran;
// }
//
// public String getDisplay() {
// return display;
// }
//
// public void setDisplay(String display) {
// this.display = display;
// }
//
// public List<String> getSeances() {
// return seances;
// }
//
// public void setSeances(List<String> seances) {
// this.seances = seances;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public boolean isToday() {
// String dateFormatted = getDate();
//
// Date now = new Date();
// SimpleDateFormat formater = new SimpleDateFormat("dd/MM/yyyy");
// String nowFormatted = formater.format(now);
//
// Log.d("DATE", dateFormatted + " " + nowFormatted);
//
// return dateFormatted.equals(nowFormatted);
// }
//
// public boolean isMoreThanToday() {
// try {
// String dateFormatted = getDate();
//
// Date now = new Date();
// now.setHours(0);
// now.setSeconds(0);
// now.setMinutes(0);
//
// SimpleDateFormat formater = new SimpleDateFormat("E dd MMMMM yyyy", Locale.FRANCE);
// Date date = formater.parse(dateFormatted);
//
// date.setHours(13);
//
// return date.equals(now) || date.after(now);
// } catch (Exception e) {
// e.printStackTrace();
// return false;
// }
// }
//
// @Override
// public String toString() {
// return "Horraires{" +
// ", date='" + date + '\'' +
// ", seances=" + seances +
// '}';
// }
// }
// Path: app/src/main/java/com/bdc/ociney/adapter/TheaterHorairesPagerAdapter.java
import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import com.bdc.ociney.fragment.FragmentTheaderDetailMoviePageHoraires;
import com.bdc.ociney.modele.Theater.Horaires;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package com.bdc.ociney.adapter;
/**
* Created by florentchampigny on 01/05/2014.
*/
public class TheaterHorairesPagerAdapter extends FragmentStatePagerAdapter {
Activity activity;
|
Map<String, List<Horaires>> horaires;
|
florent37/OCiney
|
app/src/main/java/com/bdc/ociney/adapter/TheaterHorairesPagerAdapter.java
|
// Path: app/src/main/java/com/bdc/ociney/fragment/FragmentTheaderDetailMoviePageHoraires.java
// public class FragmentTheaderDetailMoviePageHoraires extends Fragment {
//
// public static final String JOUR = "jour";
// public static final String HORAIRES = "horaires";
// String jour;
// List<Horaires> horaires;
// View view;
// TextView date;
// ViewGroup listeSeances;
//
// public static FragmentTheaderDetailMoviePageHoraires newInstance(String jour, List<Horaires> horaires) {
// FragmentTheaderDetailMoviePageHoraires fragment = new FragmentTheaderDetailMoviePageHoraires();
// Bundle args = new Bundle();
// args.putString(JOUR, jour);
//
// Gson gSon = new Gson();
// args.putString(HORAIRES, gSon.toJson(horaires));
//
// fragment.setArguments(args);
//
// return fragment;
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// super.onCreateView(inflater, container, savedInstanceState);
//
// Bundle bundle = getArguments();
// this.jour = bundle.getString(JOUR);
// Gson gSon = new Gson();
// this.horaires = gSon.fromJson(bundle.getString(HORAIRES), new TypeToken<List<Horaires>>() {
// }.getType());
//
//
// view = inflater.inflate(R.layout.fragment_theater_detail_movie_content_page_horaires, null);
//
// charger();
// remplir();
// ajouterListener();
//
// return view;
// }
//
// private void charger() {
// date = (TextView) view.findViewById(R.id.date);
// listeSeances = (ViewGroup) view.findViewById(R.id.liste_seances);
// }
//
// private void remplir() {
// date.setText(jour);
// CellTheater.chargerHoraires(listeSeances, horaires, false);
// }
//
// private void ajouterListener() {
//
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Theater/Horaires.java
// public class Horaires {
// boolean avantPremier = false;
// String date;
// String formatEcran;
// String display; //affichage complet
// List<String> seances = new ArrayList<String>();
// String version;
//
// public boolean isAvantPremier() {
// return avantPremier;
// }
//
// public void setAvantPremier(boolean avantPremier) {
// this.avantPremier = avantPremier;
// }
//
// public String getDate() {
// try {
// String[] d = date.split("-");
// return d[2] + "/" + d[1] + "/" + d[0];
// } catch (Exception e) {
// return date;
// }
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public String getFormatEcran() {
// return formatEcran;
// }
//
// public void setFormatEcran(String formatEcran) {
// this.formatEcran = formatEcran;
// }
//
// public String getDisplay() {
// return display;
// }
//
// public void setDisplay(String display) {
// this.display = display;
// }
//
// public List<String> getSeances() {
// return seances;
// }
//
// public void setSeances(List<String> seances) {
// this.seances = seances;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public boolean isToday() {
// String dateFormatted = getDate();
//
// Date now = new Date();
// SimpleDateFormat formater = new SimpleDateFormat("dd/MM/yyyy");
// String nowFormatted = formater.format(now);
//
// Log.d("DATE", dateFormatted + " " + nowFormatted);
//
// return dateFormatted.equals(nowFormatted);
// }
//
// public boolean isMoreThanToday() {
// try {
// String dateFormatted = getDate();
//
// Date now = new Date();
// now.setHours(0);
// now.setSeconds(0);
// now.setMinutes(0);
//
// SimpleDateFormat formater = new SimpleDateFormat("E dd MMMMM yyyy", Locale.FRANCE);
// Date date = formater.parse(dateFormatted);
//
// date.setHours(13);
//
// return date.equals(now) || date.after(now);
// } catch (Exception e) {
// e.printStackTrace();
// return false;
// }
// }
//
// @Override
// public String toString() {
// return "Horraires{" +
// ", date='" + date + '\'' +
// ", seances=" + seances +
// '}';
// }
// }
|
import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import com.bdc.ociney.fragment.FragmentTheaderDetailMoviePageHoraires;
import com.bdc.ociney.modele.Theater.Horaires;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
|
package com.bdc.ociney.adapter;
/**
* Created by florentchampigny on 01/05/2014.
*/
public class TheaterHorairesPagerAdapter extends FragmentStatePagerAdapter {
Activity activity;
Map<String, List<Horaires>> horaires;
List<String> jours;
HashMap<Integer, Fragment> fragmentHashMap = new HashMap<Integer, Fragment>();
public TheaterHorairesPagerAdapter(FragmentManager fm, Activity activity, List<String> jours, Map<String, List<Horaires>> horaires) {
super(fm);
this.activity = activity;
this.horaires = horaires;
this.jours = jours;
}
@Override
public Fragment getItem(final int position) {
if (fragmentHashMap.containsKey(position)) {
return fragmentHashMap.get(position);
} else {
String jour = jours.get(position);
|
// Path: app/src/main/java/com/bdc/ociney/fragment/FragmentTheaderDetailMoviePageHoraires.java
// public class FragmentTheaderDetailMoviePageHoraires extends Fragment {
//
// public static final String JOUR = "jour";
// public static final String HORAIRES = "horaires";
// String jour;
// List<Horaires> horaires;
// View view;
// TextView date;
// ViewGroup listeSeances;
//
// public static FragmentTheaderDetailMoviePageHoraires newInstance(String jour, List<Horaires> horaires) {
// FragmentTheaderDetailMoviePageHoraires fragment = new FragmentTheaderDetailMoviePageHoraires();
// Bundle args = new Bundle();
// args.putString(JOUR, jour);
//
// Gson gSon = new Gson();
// args.putString(HORAIRES, gSon.toJson(horaires));
//
// fragment.setArguments(args);
//
// return fragment;
// }
//
// @Override
// public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
// super.onCreateView(inflater, container, savedInstanceState);
//
// Bundle bundle = getArguments();
// this.jour = bundle.getString(JOUR);
// Gson gSon = new Gson();
// this.horaires = gSon.fromJson(bundle.getString(HORAIRES), new TypeToken<List<Horaires>>() {
// }.getType());
//
//
// view = inflater.inflate(R.layout.fragment_theater_detail_movie_content_page_horaires, null);
//
// charger();
// remplir();
// ajouterListener();
//
// return view;
// }
//
// private void charger() {
// date = (TextView) view.findViewById(R.id.date);
// listeSeances = (ViewGroup) view.findViewById(R.id.liste_seances);
// }
//
// private void remplir() {
// date.setText(jour);
// CellTheater.chargerHoraires(listeSeances, horaires, false);
// }
//
// private void ajouterListener() {
//
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Theater/Horaires.java
// public class Horaires {
// boolean avantPremier = false;
// String date;
// String formatEcran;
// String display; //affichage complet
// List<String> seances = new ArrayList<String>();
// String version;
//
// public boolean isAvantPremier() {
// return avantPremier;
// }
//
// public void setAvantPremier(boolean avantPremier) {
// this.avantPremier = avantPremier;
// }
//
// public String getDate() {
// try {
// String[] d = date.split("-");
// return d[2] + "/" + d[1] + "/" + d[0];
// } catch (Exception e) {
// return date;
// }
// }
//
// public void setDate(String date) {
// this.date = date;
// }
//
// public String getFormatEcran() {
// return formatEcran;
// }
//
// public void setFormatEcran(String formatEcran) {
// this.formatEcran = formatEcran;
// }
//
// public String getDisplay() {
// return display;
// }
//
// public void setDisplay(String display) {
// this.display = display;
// }
//
// public List<String> getSeances() {
// return seances;
// }
//
// public void setSeances(List<String> seances) {
// this.seances = seances;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// public boolean isToday() {
// String dateFormatted = getDate();
//
// Date now = new Date();
// SimpleDateFormat formater = new SimpleDateFormat("dd/MM/yyyy");
// String nowFormatted = formater.format(now);
//
// Log.d("DATE", dateFormatted + " " + nowFormatted);
//
// return dateFormatted.equals(nowFormatted);
// }
//
// public boolean isMoreThanToday() {
// try {
// String dateFormatted = getDate();
//
// Date now = new Date();
// now.setHours(0);
// now.setSeconds(0);
// now.setMinutes(0);
//
// SimpleDateFormat formater = new SimpleDateFormat("E dd MMMMM yyyy", Locale.FRANCE);
// Date date = formater.parse(dateFormatted);
//
// date.setHours(13);
//
// return date.equals(now) || date.after(now);
// } catch (Exception e) {
// e.printStackTrace();
// return false;
// }
// }
//
// @Override
// public String toString() {
// return "Horraires{" +
// ", date='" + date + '\'' +
// ", seances=" + seances +
// '}';
// }
// }
// Path: app/src/main/java/com/bdc/ociney/adapter/TheaterHorairesPagerAdapter.java
import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import com.bdc.ociney.fragment.FragmentTheaderDetailMoviePageHoraires;
import com.bdc.ociney.modele.Theater.Horaires;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package com.bdc.ociney.adapter;
/**
* Created by florentchampigny on 01/05/2014.
*/
public class TheaterHorairesPagerAdapter extends FragmentStatePagerAdapter {
Activity activity;
Map<String, List<Horaires>> horaires;
List<String> jours;
HashMap<Integer, Fragment> fragmentHashMap = new HashMap<Integer, Fragment>();
public TheaterHorairesPagerAdapter(FragmentManager fm, Activity activity, List<String> jours, Map<String, List<Horaires>> horaires) {
super(fm);
this.activity = activity;
this.horaires = horaires;
this.jours = jours;
}
@Override
public Fragment getItem(final int position) {
if (fragmentHashMap.containsKey(position)) {
return fragmentHashMap.get(position);
} else {
String jour = jours.get(position);
|
Fragment f = FragmentTheaderDetailMoviePageHoraires.newInstance(jour, horaires.get(jour));
|
florent37/OCiney
|
app/src/main/java/com/bdc/ociney/fragment/CreditsFragment.java
|
// Path: app/src/main/java/com/bdc/ociney/core/BaseActivity.java
// public class BaseActivity extends AppCompatActivity implements LifecycleRegistryOwner {
//
// private final LifecycleRegistry mRegistry = new LifecycleRegistry(this);
// private AdsManager adsManager;
//
// public LifecycleRegistry getLifecycle() {
// return this.mRegistry;
// }
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// adsManager = new AdsManager(this, getLifecycle());
// //if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
// // getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
// //}
// }
//
// public AdsManager getAdsManager() {
// return adsManager;
// }
//
// public MainApplication getApp() {
// return ((MainApplication) getApplication());
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/fragment/core/BaseFragment.java
// public abstract class BaseFragment extends Fragment implements View.OnClickListener {
//
// protected View fragmentView;
// boolean tournerRoulette = false;
//
// public void setFragmentView(View fragmentView) {
// this.fragmentView = fragmentView;
// }
//
// public View findViewById(int id) {
// if (fragmentView != null)
// return fragmentView.findViewById(id);
// else
// return null;
// }
//
// protected void charger(){}
//
// protected void remplir(){}
//
// protected void ajouterListeners(){}
//
// public void search(String text) {
// }
//
// public void afficherVide(boolean afficher) {
// try {
// if (afficher)
// fragmentView.findViewById(R.id.empty).setVisibility(View.VISIBLE);
// else
// fragmentView.findViewById(R.id.empty).setVisibility(View.INVISIBLE);
// } catch (Exception e) {
// }
// }
//
// protected void tournerRoulette(boolean tourner) {
// tournerRoulette(tourner, R.id.placeholder_image);
// }
//
// protected void tournerRoulette(boolean tourner, int id) {
//
// final View roulette = findViewById(id);
//
// if (roulette != null) {
// if (tourner) {
// roulette.setVisibility(View.VISIBLE);
// int previousDegrees = 0;
// int degrees = 360;
// final RotateAnimation animation = new RotateAnimation(previousDegrees, degrees,
// Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
// animation.setFillEnabled(true);
// animation.setFillAfter(true);
// animation.setDuration(1500);//Set the duration of the animation to 1 sec.
// animation.setAnimationListener(new Animation.AnimationListener() {
// @Override
// public void onAnimationStart(Animation animation) {
//
// }
//
// @Override
// public void onAnimationEnd(Animation animation) {
// if (tournerRoulette) {
// roulette.startAnimation(animation);
// } else
// roulette.animate().alpha(0).start();
// }
//
// @Override
// public void onAnimationRepeat(Animation animation) {
//
// }
// });
// roulette.startAnimation(animation);
// } else {
// tournerRoulette = false;
// }
// }
// }
//
// public void onErreurReseau() {
// //Crouton.makeText(getActivity(), R.string.erreur_reseau, Style.ALERT).show();
// Toast.makeText(getActivity(), R.string.erreur_reseau, Toast.LENGTH_SHORT).show();
// }
// }
|
import android.animation.ObjectAnimator;
import android.app.ActionBar;
import android.app.ActivityOptions;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.bdc.ociney.BuildConfig;
import com.bdc.ociney.R;
import com.bdc.ociney.core.BaseActivity;
import com.bdc.ociney.fragment.core.BaseFragment;
import butterknife.BindView;
import butterknife.ButterKnife;
|
package com.bdc.ociney.fragment;
public class CreditsFragment extends BaseFragment implements View.OnTouchListener {
@BindView(R.id.image0) View image0;
@BindView(R.id.image1) View image1;
@BindView(R.id.image2) View image2;
@BindView(R.id.version) TextView version;
public static CreditsFragment newInstance() {
Bundle args = new Bundle();
CreditsFragment fragment = new CreditsFragment();
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.credits, container, false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
setFragmentView(view);
|
// Path: app/src/main/java/com/bdc/ociney/core/BaseActivity.java
// public class BaseActivity extends AppCompatActivity implements LifecycleRegistryOwner {
//
// private final LifecycleRegistry mRegistry = new LifecycleRegistry(this);
// private AdsManager adsManager;
//
// public LifecycleRegistry getLifecycle() {
// return this.mRegistry;
// }
//
// @Override
// protected void onCreate(@Nullable Bundle savedInstanceState) {
// super.onCreate(savedInstanceState);
// adsManager = new AdsManager(this, getLifecycle());
// //if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
// // getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
// //}
// }
//
// public AdsManager getAdsManager() {
// return adsManager;
// }
//
// public MainApplication getApp() {
// return ((MainApplication) getApplication());
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/fragment/core/BaseFragment.java
// public abstract class BaseFragment extends Fragment implements View.OnClickListener {
//
// protected View fragmentView;
// boolean tournerRoulette = false;
//
// public void setFragmentView(View fragmentView) {
// this.fragmentView = fragmentView;
// }
//
// public View findViewById(int id) {
// if (fragmentView != null)
// return fragmentView.findViewById(id);
// else
// return null;
// }
//
// protected void charger(){}
//
// protected void remplir(){}
//
// protected void ajouterListeners(){}
//
// public void search(String text) {
// }
//
// public void afficherVide(boolean afficher) {
// try {
// if (afficher)
// fragmentView.findViewById(R.id.empty).setVisibility(View.VISIBLE);
// else
// fragmentView.findViewById(R.id.empty).setVisibility(View.INVISIBLE);
// } catch (Exception e) {
// }
// }
//
// protected void tournerRoulette(boolean tourner) {
// tournerRoulette(tourner, R.id.placeholder_image);
// }
//
// protected void tournerRoulette(boolean tourner, int id) {
//
// final View roulette = findViewById(id);
//
// if (roulette != null) {
// if (tourner) {
// roulette.setVisibility(View.VISIBLE);
// int previousDegrees = 0;
// int degrees = 360;
// final RotateAnimation animation = new RotateAnimation(previousDegrees, degrees,
// Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
// animation.setFillEnabled(true);
// animation.setFillAfter(true);
// animation.setDuration(1500);//Set the duration of the animation to 1 sec.
// animation.setAnimationListener(new Animation.AnimationListener() {
// @Override
// public void onAnimationStart(Animation animation) {
//
// }
//
// @Override
// public void onAnimationEnd(Animation animation) {
// if (tournerRoulette) {
// roulette.startAnimation(animation);
// } else
// roulette.animate().alpha(0).start();
// }
//
// @Override
// public void onAnimationRepeat(Animation animation) {
//
// }
// });
// roulette.startAnimation(animation);
// } else {
// tournerRoulette = false;
// }
// }
// }
//
// public void onErreurReseau() {
// //Crouton.makeText(getActivity(), R.string.erreur_reseau, Style.ALERT).show();
// Toast.makeText(getActivity(), R.string.erreur_reseau, Toast.LENGTH_SHORT).show();
// }
// }
// Path: app/src/main/java/com/bdc/ociney/fragment/CreditsFragment.java
import android.animation.ObjectAnimator;
import android.app.ActionBar;
import android.app.ActivityOptions;
import android.content.Intent;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.bdc.ociney.BuildConfig;
import com.bdc.ociney.R;
import com.bdc.ociney.core.BaseActivity;
import com.bdc.ociney.fragment.core.BaseFragment;
import butterknife.BindView;
import butterknife.ButterKnife;
package com.bdc.ociney.fragment;
public class CreditsFragment extends BaseFragment implements View.OnTouchListener {
@BindView(R.id.image0) View image0;
@BindView(R.id.image1) View image1;
@BindView(R.id.image2) View image2;
@BindView(R.id.version) TextView version;
public static CreditsFragment newInstance() {
Bundle args = new Bundle();
CreditsFragment fragment = new CreditsFragment();
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.credits, container, false);
}
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
setFragmentView(view);
|
((BaseActivity)getActivity()).getSupportActionBar().setDisplayShowTitleEnabled(true);
|
florent37/OCiney
|
app/src/main/java/com/bdc/ociney/modele/Person/CastMember.java
|
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Picture.java
// public class Picture {
//
// @Expose
// private String path;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getHref(int height) {
// return href+"/r_10000_"+height;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// @Override
// public String toString() {
// return "Picture{" +
// "path='" + path + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
|
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.ModelObject;
import com.bdc.ociney.modele.Picture;
|
package com.bdc.ociney.modele.Person;
public class CastMember {
@Expose
private PersonSmall person;
@Expose
|
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Picture.java
// public class Picture {
//
// @Expose
// private String path;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getHref(int height) {
// return href+"/r_10000_"+height;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// @Override
// public String toString() {
// return "Picture{" +
// "path='" + path + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/bdc/ociney/modele/Person/CastMember.java
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.ModelObject;
import com.bdc.ociney.modele.Picture;
package com.bdc.ociney.modele.Person;
public class CastMember {
@Expose
private PersonSmall person;
@Expose
|
private ModelObject activity;
|
florent37/OCiney
|
app/src/main/java/com/bdc/ociney/modele/Person/CastMember.java
|
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Picture.java
// public class Picture {
//
// @Expose
// private String path;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getHref(int height) {
// return href+"/r_10000_"+height;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// @Override
// public String toString() {
// return "Picture{" +
// "path='" + path + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
|
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.ModelObject;
import com.bdc.ociney.modele.Picture;
|
package com.bdc.ociney.modele.Person;
public class CastMember {
@Expose
private PersonSmall person;
@Expose
private ModelObject activity;
@Expose
|
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Picture.java
// public class Picture {
//
// @Expose
// private String path;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getHref(int height) {
// return href+"/r_10000_"+height;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// @Override
// public String toString() {
// return "Picture{" +
// "path='" + path + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/bdc/ociney/modele/Person/CastMember.java
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.ModelObject;
import com.bdc.ociney.modele.Picture;
package com.bdc.ociney.modele.Person;
public class CastMember {
@Expose
private PersonSmall person;
@Expose
private ModelObject activity;
@Expose
|
private Picture picture;
|
florent37/OCiney
|
app/src/main/java/com/bdc/ociney/modele/Person/PersonFull.java
|
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
|
import android.util.Log;
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.ModelObject;
import java.util.ArrayList;
import java.util.List;
|
package com.bdc.ociney.modele.Person;
public class PersonFull extends Person {
@Expose
private Name name;
@Expose
|
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
// Path: app/src/main/java/com/bdc/ociney/modele/Person/PersonFull.java
import android.util.Log;
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.ModelObject;
import java.util.ArrayList;
import java.util.List;
package com.bdc.ociney.modele.Person;
public class PersonFull extends Person {
@Expose
private Name name;
@Expose
|
private List<ModelObject> activity = new ArrayList<ModelObject>();
|
florent37/OCiney
|
app/src/main/java/com/bdc/ociney/modele/Movie/HelpfulPositiveReview.java
|
// Path: app/src/main/java/com/bdc/ociney/modele/Writer.java
// public class Writer {
//
// @Expose
// private String code;
// @Expose
// private String name;
// @Expose
// private String avatar;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getAvatar() {
// return avatar;
// }
//
// public void setAvatar(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return "Writer{" +
// "code='" + code + '\'' +
// ", name='" + name + '\'' +
// ", avatar='" + avatar + '\'' +
// '}';
// }
// }
|
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.Writer;
|
package com.bdc.ociney.modele.Movie;
public class HelpfulPositiveReview {
@Expose
private Integer code;
@Expose
private String creationDate;
@Expose
|
// Path: app/src/main/java/com/bdc/ociney/modele/Writer.java
// public class Writer {
//
// @Expose
// private String code;
// @Expose
// private String name;
// @Expose
// private String avatar;
//
// public String getCode() {
// return code;
// }
//
// public void setCode(String code) {
// this.code = code;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getAvatar() {
// return avatar;
// }
//
// public void setAvatar(String avatar) {
// this.avatar = avatar;
// }
//
// @Override
// public String toString() {
// return "Writer{" +
// "code='" + code + '\'' +
// ", name='" + name + '\'' +
// ", avatar='" + avatar + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/bdc/ociney/modele/Movie/HelpfulPositiveReview.java
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.Writer;
package com.bdc.ociney.modele.Movie;
public class HelpfulPositiveReview {
@Expose
private Integer code;
@Expose
private String creationDate;
@Expose
|
private Writer writer;
|
florent37/OCiney
|
app/src/main/java/com/bdc/ociney/service/AllocineService.java
|
// Path: app/src/main/java/com/bdc/ociney/modele/AllocineResponse.java
// public class AllocineResponse {
//
// @Expose
// private Feed feed;
//
// @Expose
// private Movie movie;
//
// @Expose
// private Theater theater;
//
// @Expose
// private PersonFull person;
//
// public PersonFull getPerson() {
// return person;
// }
//
// public void setPerson(PersonFull person) {
// this.person = person;
// }
//
// public Feed getFeed() {
// return feed;
// }
//
// public void setFeed(Feed feed) {
// this.feed = feed;
// }
//
// public Movie getMovie() {
// return movie;
// }
//
// public void setMovie(Movie movie) {
// this.movie = movie;
// }
//
// public Theater getTheater() {
// return theater;
// }
//
// public void setTheater(Theater theater) {
// this.theater = theater;
// }
//
// @Override
// public String toString() {
// return "Field{" +
// "feed=" + feed +
// ", movie=" + movie +
// ", person=" + person +
// ", theater=" + theater +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/AllocineResponseSmall.java
// public class AllocineResponseSmall {
//
// @Expose
// private FeedSmall feed;
//
// @Expose
// private Movie movie;
//
// @Expose
// private PersonSmall person;
//
// public PersonSmall getPerson() {
// return person;
// }
//
// public void setPerson(PersonSmall person) {
// this.person = person;
// }
//
// public FeedSmall getFeed() {
// return feed;
// }
//
// public void setFeed(FeedSmall feed) {
// this.feed = feed;
// }
//
// public Movie getMovie() {
// return movie;
// }
//
// public void setMovie(Movie movie) {
// this.movie = movie;
// }
//
// @Override
// public String toString() {
// return "Field{" +
// "feed=" + feed +
// ", movie=" + movie +
// ", person=" + person +
// '}';
// }
// }
|
import com.bdc.ociney.modele.AllocineResponse;
import com.bdc.ociney.modele.AllocineResponseSmall;
import retrofit.http.GET;
import retrofit.http.Query;
|
public static String COUNT = "count";
public static String ORDER = "order";
public static String FILTER = "filter";
public static String FORMAT = "format";
public static String DEFAULT_PARAMS = PARTNER + "=" + ALLOCINE_PARTNER_KEY + "&" + CODE + "=" + APP_ID + "&" + FORMAT + "=" + FORMAT_JSON;
public static String DEFAULT_PARAMS_MINUS_CODE = PARTNER + "=" + ALLOCINE_PARTNER_KEY + "&" + FORMAT + "=" + FORMAT_JSON;
public static String SED = "sed";
public static String SIG = "sig";
public static String Q = "q";
public static String PAGE = "page";
public static String PROFILE = "profile";
public static String ZIP = "zip";
public static String LAT = "lat";
public static String LONG = "long";
public static String RADIUS = "radius";
public static String THEATER = "theater";
public static String LOCATION = "location";
public static String TYPE = "type";
public static String MOVIE = "movie";
public static String DATE = "date";
public static String THEATERS = "theaters";
public static String SUBJECT = "subject";
public static String MEDIAFMT = "mediafmt";
//---------------------------------------------------------------------------------------------
/**
* Recherche
*/
@GET("/search?" + DEFAULT_PARAMS_MINUS_CODE)
|
// Path: app/src/main/java/com/bdc/ociney/modele/AllocineResponse.java
// public class AllocineResponse {
//
// @Expose
// private Feed feed;
//
// @Expose
// private Movie movie;
//
// @Expose
// private Theater theater;
//
// @Expose
// private PersonFull person;
//
// public PersonFull getPerson() {
// return person;
// }
//
// public void setPerson(PersonFull person) {
// this.person = person;
// }
//
// public Feed getFeed() {
// return feed;
// }
//
// public void setFeed(Feed feed) {
// this.feed = feed;
// }
//
// public Movie getMovie() {
// return movie;
// }
//
// public void setMovie(Movie movie) {
// this.movie = movie;
// }
//
// public Theater getTheater() {
// return theater;
// }
//
// public void setTheater(Theater theater) {
// this.theater = theater;
// }
//
// @Override
// public String toString() {
// return "Field{" +
// "feed=" + feed +
// ", movie=" + movie +
// ", person=" + person +
// ", theater=" + theater +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/AllocineResponseSmall.java
// public class AllocineResponseSmall {
//
// @Expose
// private FeedSmall feed;
//
// @Expose
// private Movie movie;
//
// @Expose
// private PersonSmall person;
//
// public PersonSmall getPerson() {
// return person;
// }
//
// public void setPerson(PersonSmall person) {
// this.person = person;
// }
//
// public FeedSmall getFeed() {
// return feed;
// }
//
// public void setFeed(FeedSmall feed) {
// this.feed = feed;
// }
//
// public Movie getMovie() {
// return movie;
// }
//
// public void setMovie(Movie movie) {
// this.movie = movie;
// }
//
// @Override
// public String toString() {
// return "Field{" +
// "feed=" + feed +
// ", movie=" + movie +
// ", person=" + person +
// '}';
// }
// }
// Path: app/src/main/java/com/bdc/ociney/service/AllocineService.java
import com.bdc.ociney.modele.AllocineResponse;
import com.bdc.ociney.modele.AllocineResponseSmall;
import retrofit.http.GET;
import retrofit.http.Query;
public static String COUNT = "count";
public static String ORDER = "order";
public static String FILTER = "filter";
public static String FORMAT = "format";
public static String DEFAULT_PARAMS = PARTNER + "=" + ALLOCINE_PARTNER_KEY + "&" + CODE + "=" + APP_ID + "&" + FORMAT + "=" + FORMAT_JSON;
public static String DEFAULT_PARAMS_MINUS_CODE = PARTNER + "=" + ALLOCINE_PARTNER_KEY + "&" + FORMAT + "=" + FORMAT_JSON;
public static String SED = "sed";
public static String SIG = "sig";
public static String Q = "q";
public static String PAGE = "page";
public static String PROFILE = "profile";
public static String ZIP = "zip";
public static String LAT = "lat";
public static String LONG = "long";
public static String RADIUS = "radius";
public static String THEATER = "theater";
public static String LOCATION = "location";
public static String TYPE = "type";
public static String MOVIE = "movie";
public static String DATE = "date";
public static String THEATERS = "theaters";
public static String SUBJECT = "subject";
public static String MEDIAFMT = "mediafmt";
//---------------------------------------------------------------------------------------------
/**
* Recherche
*/
@GET("/search?" + DEFAULT_PARAMS_MINUS_CODE)
|
AllocineResponse search(@Query(Q) String recherche,
|
florent37/OCiney
|
app/src/main/java/com/bdc/ociney/service/AllocineService.java
|
// Path: app/src/main/java/com/bdc/ociney/modele/AllocineResponse.java
// public class AllocineResponse {
//
// @Expose
// private Feed feed;
//
// @Expose
// private Movie movie;
//
// @Expose
// private Theater theater;
//
// @Expose
// private PersonFull person;
//
// public PersonFull getPerson() {
// return person;
// }
//
// public void setPerson(PersonFull person) {
// this.person = person;
// }
//
// public Feed getFeed() {
// return feed;
// }
//
// public void setFeed(Feed feed) {
// this.feed = feed;
// }
//
// public Movie getMovie() {
// return movie;
// }
//
// public void setMovie(Movie movie) {
// this.movie = movie;
// }
//
// public Theater getTheater() {
// return theater;
// }
//
// public void setTheater(Theater theater) {
// this.theater = theater;
// }
//
// @Override
// public String toString() {
// return "Field{" +
// "feed=" + feed +
// ", movie=" + movie +
// ", person=" + person +
// ", theater=" + theater +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/AllocineResponseSmall.java
// public class AllocineResponseSmall {
//
// @Expose
// private FeedSmall feed;
//
// @Expose
// private Movie movie;
//
// @Expose
// private PersonSmall person;
//
// public PersonSmall getPerson() {
// return person;
// }
//
// public void setPerson(PersonSmall person) {
// this.person = person;
// }
//
// public FeedSmall getFeed() {
// return feed;
// }
//
// public void setFeed(FeedSmall feed) {
// this.feed = feed;
// }
//
// public Movie getMovie() {
// return movie;
// }
//
// public void setMovie(Movie movie) {
// this.movie = movie;
// }
//
// @Override
// public String toString() {
// return "Field{" +
// "feed=" + feed +
// ", movie=" + movie +
// ", person=" + person +
// '}';
// }
// }
|
import com.bdc.ociney.modele.AllocineResponse;
import com.bdc.ociney.modele.AllocineResponseSmall;
import retrofit.http.GET;
import retrofit.http.Query;
|
public static String THEATER = "theater";
public static String LOCATION = "location";
public static String TYPE = "type";
public static String MOVIE = "movie";
public static String DATE = "date";
public static String THEATERS = "theaters";
public static String SUBJECT = "subject";
public static String MEDIAFMT = "mediafmt";
//---------------------------------------------------------------------------------------------
/**
* Recherche
*/
@GET("/search?" + DEFAULT_PARAMS_MINUS_CODE)
AllocineResponse search(@Query(Q) String recherche,
@Query(FILTER) String filer,
@Query(COUNT) int count,
@Query(PAGE) int page,
@Query(SED) String sed,
@Query(SIG) String sig
);
//---------------------------------------------------------------------------------------------
/**
* Recherche Small
*/
@GET("/search?" + DEFAULT_PARAMS_MINUS_CODE)
|
// Path: app/src/main/java/com/bdc/ociney/modele/AllocineResponse.java
// public class AllocineResponse {
//
// @Expose
// private Feed feed;
//
// @Expose
// private Movie movie;
//
// @Expose
// private Theater theater;
//
// @Expose
// private PersonFull person;
//
// public PersonFull getPerson() {
// return person;
// }
//
// public void setPerson(PersonFull person) {
// this.person = person;
// }
//
// public Feed getFeed() {
// return feed;
// }
//
// public void setFeed(Feed feed) {
// this.feed = feed;
// }
//
// public Movie getMovie() {
// return movie;
// }
//
// public void setMovie(Movie movie) {
// this.movie = movie;
// }
//
// public Theater getTheater() {
// return theater;
// }
//
// public void setTheater(Theater theater) {
// this.theater = theater;
// }
//
// @Override
// public String toString() {
// return "Field{" +
// "feed=" + feed +
// ", movie=" + movie +
// ", person=" + person +
// ", theater=" + theater +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/AllocineResponseSmall.java
// public class AllocineResponseSmall {
//
// @Expose
// private FeedSmall feed;
//
// @Expose
// private Movie movie;
//
// @Expose
// private PersonSmall person;
//
// public PersonSmall getPerson() {
// return person;
// }
//
// public void setPerson(PersonSmall person) {
// this.person = person;
// }
//
// public FeedSmall getFeed() {
// return feed;
// }
//
// public void setFeed(FeedSmall feed) {
// this.feed = feed;
// }
//
// public Movie getMovie() {
// return movie;
// }
//
// public void setMovie(Movie movie) {
// this.movie = movie;
// }
//
// @Override
// public String toString() {
// return "Field{" +
// "feed=" + feed +
// ", movie=" + movie +
// ", person=" + person +
// '}';
// }
// }
// Path: app/src/main/java/com/bdc/ociney/service/AllocineService.java
import com.bdc.ociney.modele.AllocineResponse;
import com.bdc.ociney.modele.AllocineResponseSmall;
import retrofit.http.GET;
import retrofit.http.Query;
public static String THEATER = "theater";
public static String LOCATION = "location";
public static String TYPE = "type";
public static String MOVIE = "movie";
public static String DATE = "date";
public static String THEATERS = "theaters";
public static String SUBJECT = "subject";
public static String MEDIAFMT = "mediafmt";
//---------------------------------------------------------------------------------------------
/**
* Recherche
*/
@GET("/search?" + DEFAULT_PARAMS_MINUS_CODE)
AllocineResponse search(@Query(Q) String recherche,
@Query(FILTER) String filer,
@Query(COUNT) int count,
@Query(PAGE) int page,
@Query(SED) String sed,
@Query(SIG) String sig
);
//---------------------------------------------------------------------------------------------
/**
* Recherche Small
*/
@GET("/search?" + DEFAULT_PARAMS_MINUS_CODE)
|
AllocineResponseSmall searchSmall(@Query(Q) String recherche,
|
florent37/OCiney
|
app/src/main/java/com/bdc/ociney/modele/Theater/Theater.java
|
// Path: app/src/main/java/com/bdc/ociney/modele/Geoloc.java
// public class Geoloc {
//
// @Expose
// private Double lat;
// @SerializedName("long")
// @Expose
// private Double _long;
//
// public Double getLat() {
// return lat;
// }
//
// public void setLat(Double lat) {
// this.lat = lat;
// }
//
// public Double getLong() {
// return _long;
// }
//
// public void setLong(Double _long) {
// this._long = _long;
// }
//
// @Override
// public String toString() {
// return "Geoloc{" +
// "lat=" + lat +
// ", _long=" + _long +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Link.java
// public class Link {
//
// @Expose
// private String rel;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getRel() {
// return rel;
// }
//
// public void setRel(String rel) {
// this.rel = rel;
// }
//
// public String getHref() {
// return href;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Link{" +
// "rel='" + rel + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Picture.java
// public class Picture {
//
// @Expose
// private String path;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getHref(int height) {
// return href+"/r_10000_"+height;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// @Override
// public String toString() {
// return "Picture{" +
// "path='" + path + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
|
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.Geoloc;
import com.bdc.ociney.modele.Link;
import com.bdc.ociney.modele.ModelObject;
import com.bdc.ociney.modele.Picture;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
|
package com.bdc.ociney.modele.Theater;
public class Theater {
public List<TheaterShowtime> showTimes;
private List<Horaires> horaires = new ArrayList<Horaires>();
private Map<String, List<Horaires>> horairesSemaine = new HashMap<String, List<Horaires>>();
private List<String> horairesSemaineJours = new ArrayList<String>();
@Expose
private String code;
@Expose
private Double distance;
@Expose
private String name;
@Expose
private String address;
@Expose
private String postalCode;
@Expose
private String city;
@Expose
|
// Path: app/src/main/java/com/bdc/ociney/modele/Geoloc.java
// public class Geoloc {
//
// @Expose
// private Double lat;
// @SerializedName("long")
// @Expose
// private Double _long;
//
// public Double getLat() {
// return lat;
// }
//
// public void setLat(Double lat) {
// this.lat = lat;
// }
//
// public Double getLong() {
// return _long;
// }
//
// public void setLong(Double _long) {
// this._long = _long;
// }
//
// @Override
// public String toString() {
// return "Geoloc{" +
// "lat=" + lat +
// ", _long=" + _long +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Link.java
// public class Link {
//
// @Expose
// private String rel;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getRel() {
// return rel;
// }
//
// public void setRel(String rel) {
// this.rel = rel;
// }
//
// public String getHref() {
// return href;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Link{" +
// "rel='" + rel + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Picture.java
// public class Picture {
//
// @Expose
// private String path;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getHref(int height) {
// return href+"/r_10000_"+height;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// @Override
// public String toString() {
// return "Picture{" +
// "path='" + path + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/bdc/ociney/modele/Theater/Theater.java
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.Geoloc;
import com.bdc.ociney.modele.Link;
import com.bdc.ociney.modele.ModelObject;
import com.bdc.ociney.modele.Picture;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package com.bdc.ociney.modele.Theater;
public class Theater {
public List<TheaterShowtime> showTimes;
private List<Horaires> horaires = new ArrayList<Horaires>();
private Map<String, List<Horaires>> horairesSemaine = new HashMap<String, List<Horaires>>();
private List<String> horairesSemaineJours = new ArrayList<String>();
@Expose
private String code;
@Expose
private Double distance;
@Expose
private String name;
@Expose
private String address;
@Expose
private String postalCode;
@Expose
private String city;
@Expose
|
private Picture picture;
|
florent37/OCiney
|
app/src/main/java/com/bdc/ociney/modele/Theater/Theater.java
|
// Path: app/src/main/java/com/bdc/ociney/modele/Geoloc.java
// public class Geoloc {
//
// @Expose
// private Double lat;
// @SerializedName("long")
// @Expose
// private Double _long;
//
// public Double getLat() {
// return lat;
// }
//
// public void setLat(Double lat) {
// this.lat = lat;
// }
//
// public Double getLong() {
// return _long;
// }
//
// public void setLong(Double _long) {
// this._long = _long;
// }
//
// @Override
// public String toString() {
// return "Geoloc{" +
// "lat=" + lat +
// ", _long=" + _long +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Link.java
// public class Link {
//
// @Expose
// private String rel;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getRel() {
// return rel;
// }
//
// public void setRel(String rel) {
// this.rel = rel;
// }
//
// public String getHref() {
// return href;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Link{" +
// "rel='" + rel + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Picture.java
// public class Picture {
//
// @Expose
// private String path;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getHref(int height) {
// return href+"/r_10000_"+height;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// @Override
// public String toString() {
// return "Picture{" +
// "path='" + path + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
|
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.Geoloc;
import com.bdc.ociney.modele.Link;
import com.bdc.ociney.modele.ModelObject;
import com.bdc.ociney.modele.Picture;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
|
package com.bdc.ociney.modele.Theater;
public class Theater {
public List<TheaterShowtime> showTimes;
private List<Horaires> horaires = new ArrayList<Horaires>();
private Map<String, List<Horaires>> horairesSemaine = new HashMap<String, List<Horaires>>();
private List<String> horairesSemaineJours = new ArrayList<String>();
@Expose
private String code;
@Expose
private Double distance;
@Expose
private String name;
@Expose
private String address;
@Expose
private String postalCode;
@Expose
private String city;
@Expose
private Picture picture;
@Expose
|
// Path: app/src/main/java/com/bdc/ociney/modele/Geoloc.java
// public class Geoloc {
//
// @Expose
// private Double lat;
// @SerializedName("long")
// @Expose
// private Double _long;
//
// public Double getLat() {
// return lat;
// }
//
// public void setLat(Double lat) {
// this.lat = lat;
// }
//
// public Double getLong() {
// return _long;
// }
//
// public void setLong(Double _long) {
// this._long = _long;
// }
//
// @Override
// public String toString() {
// return "Geoloc{" +
// "lat=" + lat +
// ", _long=" + _long +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Link.java
// public class Link {
//
// @Expose
// private String rel;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getRel() {
// return rel;
// }
//
// public void setRel(String rel) {
// this.rel = rel;
// }
//
// public String getHref() {
// return href;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Link{" +
// "rel='" + rel + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Picture.java
// public class Picture {
//
// @Expose
// private String path;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getHref(int height) {
// return href+"/r_10000_"+height;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// @Override
// public String toString() {
// return "Picture{" +
// "path='" + path + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/bdc/ociney/modele/Theater/Theater.java
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.Geoloc;
import com.bdc.ociney.modele.Link;
import com.bdc.ociney.modele.ModelObject;
import com.bdc.ociney.modele.Picture;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package com.bdc.ociney.modele.Theater;
public class Theater {
public List<TheaterShowtime> showTimes;
private List<Horaires> horaires = new ArrayList<Horaires>();
private Map<String, List<Horaires>> horairesSemaine = new HashMap<String, List<Horaires>>();
private List<String> horairesSemaineJours = new ArrayList<String>();
@Expose
private String code;
@Expose
private Double distance;
@Expose
private String name;
@Expose
private String address;
@Expose
private String postalCode;
@Expose
private String city;
@Expose
private Picture picture;
@Expose
|
private Geoloc geoloc;
|
florent37/OCiney
|
app/src/main/java/com/bdc/ociney/modele/Theater/Theater.java
|
// Path: app/src/main/java/com/bdc/ociney/modele/Geoloc.java
// public class Geoloc {
//
// @Expose
// private Double lat;
// @SerializedName("long")
// @Expose
// private Double _long;
//
// public Double getLat() {
// return lat;
// }
//
// public void setLat(Double lat) {
// this.lat = lat;
// }
//
// public Double getLong() {
// return _long;
// }
//
// public void setLong(Double _long) {
// this._long = _long;
// }
//
// @Override
// public String toString() {
// return "Geoloc{" +
// "lat=" + lat +
// ", _long=" + _long +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Link.java
// public class Link {
//
// @Expose
// private String rel;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getRel() {
// return rel;
// }
//
// public void setRel(String rel) {
// this.rel = rel;
// }
//
// public String getHref() {
// return href;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Link{" +
// "rel='" + rel + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Picture.java
// public class Picture {
//
// @Expose
// private String path;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getHref(int height) {
// return href+"/r_10000_"+height;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// @Override
// public String toString() {
// return "Picture{" +
// "path='" + path + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
|
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.Geoloc;
import com.bdc.ociney.modele.Link;
import com.bdc.ociney.modele.ModelObject;
import com.bdc.ociney.modele.Picture;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
|
package com.bdc.ociney.modele.Theater;
public class Theater {
public List<TheaterShowtime> showTimes;
private List<Horaires> horaires = new ArrayList<Horaires>();
private Map<String, List<Horaires>> horairesSemaine = new HashMap<String, List<Horaires>>();
private List<String> horairesSemaineJours = new ArrayList<String>();
@Expose
private String code;
@Expose
private Double distance;
@Expose
private String name;
@Expose
private String address;
@Expose
private String postalCode;
@Expose
private String city;
@Expose
private Picture picture;
@Expose
private Geoloc geoloc;
@Expose
|
// Path: app/src/main/java/com/bdc/ociney/modele/Geoloc.java
// public class Geoloc {
//
// @Expose
// private Double lat;
// @SerializedName("long")
// @Expose
// private Double _long;
//
// public Double getLat() {
// return lat;
// }
//
// public void setLat(Double lat) {
// this.lat = lat;
// }
//
// public Double getLong() {
// return _long;
// }
//
// public void setLong(Double _long) {
// this._long = _long;
// }
//
// @Override
// public String toString() {
// return "Geoloc{" +
// "lat=" + lat +
// ", _long=" + _long +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Link.java
// public class Link {
//
// @Expose
// private String rel;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getRel() {
// return rel;
// }
//
// public void setRel(String rel) {
// this.rel = rel;
// }
//
// public String getHref() {
// return href;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Link{" +
// "rel='" + rel + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Picture.java
// public class Picture {
//
// @Expose
// private String path;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getHref(int height) {
// return href+"/r_10000_"+height;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// @Override
// public String toString() {
// return "Picture{" +
// "path='" + path + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/bdc/ociney/modele/Theater/Theater.java
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.Geoloc;
import com.bdc.ociney.modele.Link;
import com.bdc.ociney.modele.ModelObject;
import com.bdc.ociney.modele.Picture;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package com.bdc.ociney.modele.Theater;
public class Theater {
public List<TheaterShowtime> showTimes;
private List<Horaires> horaires = new ArrayList<Horaires>();
private Map<String, List<Horaires>> horairesSemaine = new HashMap<String, List<Horaires>>();
private List<String> horairesSemaineJours = new ArrayList<String>();
@Expose
private String code;
@Expose
private Double distance;
@Expose
private String name;
@Expose
private String address;
@Expose
private String postalCode;
@Expose
private String city;
@Expose
private Picture picture;
@Expose
private Geoloc geoloc;
@Expose
|
private List<Link> link = new ArrayList<Link>();
|
florent37/OCiney
|
app/src/main/java/com/bdc/ociney/modele/Theater/Theater.java
|
// Path: app/src/main/java/com/bdc/ociney/modele/Geoloc.java
// public class Geoloc {
//
// @Expose
// private Double lat;
// @SerializedName("long")
// @Expose
// private Double _long;
//
// public Double getLat() {
// return lat;
// }
//
// public void setLat(Double lat) {
// this.lat = lat;
// }
//
// public Double getLong() {
// return _long;
// }
//
// public void setLong(Double _long) {
// this._long = _long;
// }
//
// @Override
// public String toString() {
// return "Geoloc{" +
// "lat=" + lat +
// ", _long=" + _long +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Link.java
// public class Link {
//
// @Expose
// private String rel;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getRel() {
// return rel;
// }
//
// public void setRel(String rel) {
// this.rel = rel;
// }
//
// public String getHref() {
// return href;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Link{" +
// "rel='" + rel + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Picture.java
// public class Picture {
//
// @Expose
// private String path;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getHref(int height) {
// return href+"/r_10000_"+height;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// @Override
// public String toString() {
// return "Picture{" +
// "path='" + path + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
|
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.Geoloc;
import com.bdc.ociney.modele.Link;
import com.bdc.ociney.modele.ModelObject;
import com.bdc.ociney.modele.Picture;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
|
package com.bdc.ociney.modele.Theater;
public class Theater {
public List<TheaterShowtime> showTimes;
private List<Horaires> horaires = new ArrayList<Horaires>();
private Map<String, List<Horaires>> horairesSemaine = new HashMap<String, List<Horaires>>();
private List<String> horairesSemaineJours = new ArrayList<String>();
@Expose
private String code;
@Expose
private Double distance;
@Expose
private String name;
@Expose
private String address;
@Expose
private String postalCode;
@Expose
private String city;
@Expose
private Picture picture;
@Expose
private Geoloc geoloc;
@Expose
private List<Link> link = new ArrayList<Link>();
@Expose
|
// Path: app/src/main/java/com/bdc/ociney/modele/Geoloc.java
// public class Geoloc {
//
// @Expose
// private Double lat;
// @SerializedName("long")
// @Expose
// private Double _long;
//
// public Double getLat() {
// return lat;
// }
//
// public void setLat(Double lat) {
// this.lat = lat;
// }
//
// public Double getLong() {
// return _long;
// }
//
// public void setLong(Double _long) {
// this._long = _long;
// }
//
// @Override
// public String toString() {
// return "Geoloc{" +
// "lat=" + lat +
// ", _long=" + _long +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Link.java
// public class Link {
//
// @Expose
// private String rel;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getRel() {
// return rel;
// }
//
// public void setRel(String rel) {
// this.rel = rel;
// }
//
// public String getHref() {
// return href;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// @Override
// public String toString() {
// return "Link{" +
// "rel='" + rel + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
//
// Path: app/src/main/java/com/bdc/ociney/modele/Picture.java
// public class Picture {
//
// @Expose
// private String path;
// @Expose
// private String href;
// @Expose
// private String name;
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getPath() {
// return path;
// }
//
// public void setPath(String path) {
// this.path = path;
// }
//
// public String getHref(int height) {
// return href+"/r_10000_"+height;
// }
//
// public void setHref(String href) {
// this.href = href;
// }
//
// @Override
// public String toString() {
// return "Picture{" +
// "path='" + path + '\'' +
// ", href='" + href + '\'' +
// ", name='" + name + '\'' +
// '}';
// }
// }
// Path: app/src/main/java/com/bdc/ociney/modele/Theater/Theater.java
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.Geoloc;
import com.bdc.ociney.modele.Link;
import com.bdc.ociney.modele.ModelObject;
import com.bdc.ociney.modele.Picture;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
package com.bdc.ociney.modele.Theater;
public class Theater {
public List<TheaterShowtime> showTimes;
private List<Horaires> horaires = new ArrayList<Horaires>();
private Map<String, List<Horaires>> horairesSemaine = new HashMap<String, List<Horaires>>();
private List<String> horairesSemaineJours = new ArrayList<String>();
@Expose
private String code;
@Expose
private Double distance;
@Expose
private String name;
@Expose
private String address;
@Expose
private String postalCode;
@Expose
private String city;
@Expose
private Picture picture;
@Expose
private Geoloc geoloc;
@Expose
private List<Link> link = new ArrayList<Link>();
@Expose
|
private ModelObject cinemaChain;
|
florent37/OCiney
|
app/src/main/java/com/bdc/ociney/modele/Theater/Scr.java
|
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
|
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.ModelObject;
import java.util.ArrayList;
import java.util.List;
|
package com.bdc.ociney.modele.Theater;
public class Scr {
@Expose
private String d;
@Expose
|
// Path: app/src/main/java/com/bdc/ociney/modele/ModelObject.java
// public class ModelObject {
//
// @Expose
// private Integer code;
// @Expose
// private String value;
// @Expose
// private String $;
// @Expose
// private Integer p;
// @Expose
// private Double note;
// @Expose
// private String type;
//
// public Integer getCode() {
// return code;
// }
//
// public void setCode(Integer code) {
// this.code = code;
// }
//
// public String getValue() {
// return value;
// }
//
// public void setValue(String value) {
// this.value = value;
// }
//
// public String get$() {
// return $;
// }
//
// public void set$(String $) {
// this.$ = $;
// }
//
// public Integer getP() {
// return p;
// }
//
// public void setP(Integer p) {
// this.p = p;
// }
//
// public Double getNote() {
// return note;
// }
//
// public void setNote(Double note) {
// this.note = note;
// }
//
// public String getType() {
// return type;
// }
//
// public void setType(String type) {
// this.type = type;
// }
//
// public void setScheme(String scheme) {
// this.value = scheme;
// }
//
// @Override
// public String toString() {
// return "ModelObject{" +
// "code=" + code +
// ", $= " + $ +
// ", value='" + value + '\'' +
// ", p=" + p +
// ", type= " + type +
// ", note=" + note +
// '}';
// }
// }
// Path: app/src/main/java/com/bdc/ociney/modele/Theater/Scr.java
import com.google.gson.annotations.Expose;
import com.bdc.ociney.modele.ModelObject;
import java.util.ArrayList;
import java.util.List;
package com.bdc.ociney.modele.Theater;
public class Scr {
@Expose
private String d;
@Expose
|
private List<ModelObject> t = new ArrayList<ModelObject>();
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.