初始化提交项目的源代码

This commit is contained in:
Yucheng Hu 2017-07-22 23:54:54 -04:00
parent 34bc7cfd68
commit 0c9a229ce8
35 changed files with 3645 additions and 0 deletions

30
core/README.md Normal file
View File

@ -0,0 +1,30 @@
#关于 USVisaTrack 项目
--------
USVisaTrack 是一个基于数据的商品信息平台
#关于 USVisaTrack 这个仓库
--------
#JDK 配置
--------
JDK 需要使用 1.8 以上的版本。
#安装
--------
#SCM
--------
https://gitlab.com/ntc/us-visa-track
#文档
--------
https://www.cwiki.us
#论坛
--------
www.ossez.com

291
core/pom.xml Normal file
View File

@ -0,0 +1,291 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.usvisatrack</groupId>
<artifactId>usvisatrack-main</artifactId>
<version>0.1.0</version>
</parent>
<artifactId>usvisatrack-core</artifactId>
<name>usvisatrack core</name>
<description>usvisatrack core code and view files to render HTML.</description>
<properties>
<staplerFork>true</staplerFork>
<stapler.version>1.250</stapler.version>
<spring.version>2.5.6.SEC03</spring.version>
<groovy.version>2.4.11</groovy.version>
<!-- TODO: Actually many issues are being filtered by src/findbugs/findbugs-excludes.xml -->
<findbugs.failOnError>true</findbugs.failOnError>
</properties>
<dependencies>
<!-- DATABASE AND HIBERNATE -->
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>1.5.9</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>5.1.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-ehcache</artifactId>
<version>5.1.2.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>5.5.5.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.2.4.Final</version>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>5.5.3</version>
</dependency>
<!-- /DATABASE AND HIBERNATE -->
<!-- APACHE COMMONS -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.0</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
<version>1.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<!-- /APACHE COMMONS -->
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>gov.nih.imagej</groupId>
<artifactId>imagej</artifactId>
<version>1.47</version>
</dependency>
<dependency>
<groupId>net.sf.barcode4j</groupId>
<artifactId>barcode4j</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.2.1</version>
</dependency>
<!-- /UTILITIES -->
<!--/CLOUDS -->
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk</artifactId>
<version>1.11.114</version>
</dependency>
<dependency>
<groupId>com.paypal.sdk</groupId>
<artifactId>paypal-core</artifactId>
<version>1.7.2</version>
</dependency>
<dependency>
<groupId>com.paypal.sdk</groupId>
<artifactId>rest-api-sdk</artifactId>
<version>1.13.0</version>
</dependency>
<!--/CLOUDS -->
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.7</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>4.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.6.9</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>1.1.6</version>
</dependency>
</dependencies>
<build>
<plugins></plugins>
</build>
<reporting>
<plugins>
<plugin><!-- generate Jelly tag lib documentation -->
<groupId>org.kohsuke.stapler</groupId>
<artifactId>maven-stapler-plugin</artifactId>
<version>${maven-stapler-plugin.version}</version>
<configuration>
<patterns>
<pattern>/lib/.*</pattern>
</patterns>
</configuration>
</plugin>
<plugin><!-- skip slow dependency analysis -->
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.6</version>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
</plugin>
</plugins>
</reporting>
<profiles>
<profile>
<id>debug</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<!-- generate jelly taglib docs from src/main/resources. this is necessary in addition to the <reporting> configuration to get the results
deployed. -->
<groupId>org.kohsuke.stapler</groupId>
<artifactId>maven-stapler-plugin</artifactId>
<!-- version specified in grandparent pom -->
<executions>
<execution>
<goals>
<goal>jelly-taglibdoc</goal>
</goals>
<configuration>
<patterns>
<pattern>/lib/.*</pattern>
</patterns>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<!-- Run FindBugs for better error detection. Run as "mvn -Pfindbugs install site". -->
<!-- FindBugs has been moved to the default build flow, but here we fail the build on errors -->
<id>findbugs</id>
<properties>
<!-- In the default profile we always fail the build if there FindBugs errors -->
<findbugs.failOnError>true</findbugs.failOnError>
</properties>
</profile>
<profile>
<!-- Obtain code coverage report. This is done by running Unit tests on our own and suppressing surefire. -->
<id>cobertura</id>
<build>
<plugins>
<plugin>
<!-- unit tests are run by GMaven through Ant. -->
<artifactId>maven-surefire-plugin</artifactId>
<!-- version specified in grandparent pom -->
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@ -0,0 +1,2 @@
Manifest-Version: 1.0
Class-Path:

View File

@ -0,0 +1,95 @@
package com.usvisatrack.core.cloud;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.amazonaws.AmazonClientException;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.AmazonS3Client;
import com.amazonaws.services.s3.model.PutObjectRequest;
/**
* BcoDepot Amazon Utils class
*
* @author YuCheng Hu
*
*/
/**
* Common class to handle the movement of files into the Cloud (in this case Rackspace Cloud Files).
*
* @author YuCheng Hu
*
*/
public class AwsS3 implements Closeable {
private static Logger logger = LoggerFactory.getLogger(AwsS3.class);
private static AwsS3 instance = null;
private static String accessKey = null;
private static String secreKey = null;
/**
* Constructor Function
*/
public AwsS3() {
accessKey = "AKIAI6CDTBEK6PF3QBMA";
secreKey = "F15vscDOpQ3Ac0L08eICSGw55ZlM6qbXgEuboB0B";
}
public static AwsS3 getInstance() {
if (instance == null) {
instance = new AwsS3();
}
return instance;
}
/**
* Upload files of given directory to Cloud Files Path
*
* @param bucketName
* @param remotePath
* @param file
* @throws Exception
*/
public static void UploadObjectSingleOperation(String bucketName, String remotePath, File file) throws Exception {
BasicAWSCredentials awsCreds = new BasicAWSCredentials(accessKey, secreKey);
AmazonS3 s3client = new AmazonS3Client(awsCreds);
// AmazonS3 s3client = new AmazonS3Client(new ProfileCredentialsProvider());
try {
System.out.println("Uploading a new object to S3 from a file\n");
s3client.putObject(new PutObjectRequest(bucketName, remotePath, file));
} catch (AmazonServiceException ase) {
System.out.println("Caught an AmazonServiceException, which " + "means your request made it "
+ "to Amazon S3, but was rejected with an error response" + " for some reason.");
System.out.println("Error Message: " + ase.getMessage());
System.out.println("HTTP Status Code: " + ase.getStatusCode());
System.out.println("AWS Error Code: " + ase.getErrorCode());
System.out.println("Error Type: " + ase.getErrorType());
System.out.println("Request ID: " + ase.getRequestId());
} catch (AmazonClientException ace) {
System.out.println("Caught an AmazonClientException, which " + "means the client encountered "
+ "an internal error while trying to " + "communicate with S3, " + "such as not being able to access the network.");
System.out.println("Error Message: " + ace.getMessage());
}
} // End uploadDirectoryContentsToCloud
@Override
public void close() throws IOException {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,127 @@
package com.usvisatrack.core.common;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import org.hibernate.search.annotations.DateBridge;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Resolution;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.usvisatrack.core.dao.model.EntityListener;
/**
*
* @author YuCheng Hu
*
*/
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE, getterVisibility = JsonAutoDetect.Visibility.NONE, setterVisibility = JsonAutoDetect.Visibility.NONE, isGetterVisibility = JsonAutoDetect.Visibility.NONE, creatorVisibility = JsonAutoDetect.Visibility.NONE)
@EntityListeners({EntityListener.class})
@MappedSuperclass
public abstract class DataObject implements Serializable {
public abstract interface Save {
}
public abstract interface Update {
}
private static final long serialVersionUID = -67188388306700736L;
public static final String ID_PROPERTY_NAME = "id";
public static final String CREATE_DATE_PROPERTY_NAME = "createDate";
public static final String MODIFY_DATE_PROPERTY_NAME = "modifyDate";
private Long id;
private Date createDate;
private Date modifyDate;
/**
*
* @return
*/
@JsonProperty
@DocumentId
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getId() {
return this.id;
}
/**
*
* @param id
*/
public void setId(Long id) {
this.id = id;
}
/**
*
* @return
*/
@JsonProperty
@DateBridge(resolution = Resolution.SECOND)
@Column(nullable = false, updatable = false)
public Date getCreateDate() {
return this.createDate;
}
/**
*
* @param createDate
*/
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
/**
*
* @return
*/
@JsonProperty
@DateBridge(resolution = Resolution.SECOND)
@Column(nullable = false)
public Date getModifyDate() {
return this.modifyDate;
}
/**
*
* @param modifyDate
*/
public void setModifyDate(Date modifyDate) {
this.modifyDate = modifyDate;
}
/**
*
*/
public boolean equals(Object obj) {
if (obj == null)
return false;
if (this == obj)
return true;
if (!DataObject.class.isAssignableFrom(obj.getClass()))
return false;
DataObject localBaseEntity = (DataObject) obj;
return getId() != null ? getId().equals(localBaseEntity.getId()) : false;
}
/**
*
*/
public int hashCode() {
int i = 17;
i += (getId() == null ? 0 : getId().hashCode() * 31);
return i;
}
}

View File

@ -0,0 +1,497 @@
package com.usvisatrack.core.common;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Date;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import org.hibernate.resource.transaction.spi.TransactionStatus;
import org.hibernate.search.FullTextSession;
import org.hibernate.search.Search;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.usvisatrack.core.common.search.InternalSearch;
import com.usvisatrack.core.dao.model.User;
/**
*
* @author YuCheng Hu
*
*/
public class Factory {
private static SessionFactory factory = null;
private static Logger logger = LoggerFactory.getLogger(Factory.class);
private static SessionFactory sessionFactory;
// private static ServiceRegistry serviceRegistry;
private static int indexBatchSize = 100;
private static boolean noCommit = false; // blocks the commit function from
// being called - this is useful
// for unit testing.
private static boolean autoRollback = false; // executes a rollback instead
// of a commit when commit
// is called - this is
// useful for unit
// testing.
private static boolean noClose = false; // prevents the connection from
// being closed. This is useful for
// unit testing.
/**
* Get Hibernate connection Session
*
* @return
*/
public static Session getSession() {
return Factory.getFactory().getCurrentSession();
}
/**
* Get session connection Get
*
* @return
*/
public static SessionFactory getFactory() {
if (Factory.factory == null)
Factory.factory = Factory.initSession();
return Factory.factory;
}
/**
*
* @return
*/
public static SessionFactory initSession() {
// Hibernate 4 init Session
// return new Configuration().configure().buildSessionFactory();
// Configuration configuration = new Configuration();
// configuration.configure();
// serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();
// sessionFactory = configuration.buildSessionFactory(serviceRegistry);
// Hibernate 5 init Session
// configures settings from hibernate.cfg.xml
final StandardServiceRegistry registry = new StandardServiceRegistryBuilder().configure().build();
try {
sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
} catch (Exception e) {
logger.error("HIBERNATE DB SESSION INIT ERROR", e);
// The registry would be destroyed by the SessionFactory, but we had trouble building the SessionFactory
// so destroy it manually.
StandardServiceRegistryBuilder.destroy(registry);
}
return sessionFactory;
}
/**
*
*/
public static void beginTransaction() {
// If transaction not exist, create one
if (!(Factory.getSession().getTransaction() != null
&& Factory.getSession().getTransaction().getStatus() == TransactionStatus.ACTIVE)) {
Factory.getSession().getTransaction().begin();
}
}
public static Transaction getTransaction() {
return Factory.getSession().beginTransaction();
}
public static void commitTransaction() {
if (isAutoRollback()) {
Factory.rollbackTransaction();
return;
}
if (Factory.getSession().getTransaction() != null
&& Factory.getSession().getTransaction().getStatus() == TransactionStatus.ACTIVE) {
if (!noCommit)
Factory.getSession().getTransaction().commit();
// zhaohc
Factory.getSession().close();
}
}
public static void commitTransaction(Transaction tx) {
if (isAutoRollback()) {
tx.rollback();
}
if (tx != null && tx.getStatus() == TransactionStatus.ACTIVE) {
if (!noCommit)
tx.commit();
}
}
public static void rollbackTransaction() {
if (Factory.getSession().getTransaction() != null && Factory.getSession().getTransaction().getStatus() == TransactionStatus.ACTIVE)
Factory.getSession().getTransaction().rollback();
}
public static void rollbackTransaction(Transaction tx) {
if (tx != null && tx.getStatus() == TransactionStatus.ACTIVE)
tx.rollback();
}
/**
* Gets an object of type T from Hibernate.
*
* @param <T>
* @param classEntity
* @param id
* @return
*/
@SuppressWarnings("unchecked")
public static <T> T get(Class<T> classEntity, long id) {
Object object = Factory.getSession().get(classEntity, id);
if (object == null)
return null;
return (T) object;
}
/**
* Saves the specified object to the database.
*
* @param <T>
* @param object
*/
public static void save(DataObject object) {
if (object == null)
throw new NullPointerException("Object supplied is null");
if (object.getId() != null && object.getId() > 0)
Factory.getSession().saveOrUpdate(object);
else {
Factory.getSession().save(object);
}
}
public static void saveUsers(User users) {
if (users == null)
throw new NullPointerException("Object supplied is null");
Factory.getSession().save(users);
}
public static void updateUsers(User users) {
if (users == null)
throw new NullPointerException("Object supplied is null");
Factory.getSession().update(users);
}
/**
* Deletes the specified object.
*
* @param <T>
* @param object
*/
public static void delete(DataObject object) {
try {
Factory.beginTransaction();
Factory.getSession().delete(object);
Factory.commitTransaction();
} catch (Exception ex) {
logger.error("DB Record Delete Error:", ex);
Factory.rollbackTransaction();
}
}
/**
* Creates an hibernate criteria object which is used to query against objects.
*
* @param classArg
* @return
*/
public static <T> Criteria createCriteria(Class<T> classArg) {
Criteria criteria = Factory.getSession().createCriteria(classArg);
// Factory.commitTransaction();
return criteria;
}
/**
* Creates an hibernate criteria object with the specified alias.
*
* @param classArg
* @param alias
* @return
*/
public static <T> Criteria createCriteria(Class<T> classArg, String alias) {
return Factory.getSession().createCriteria(classArg, alias);
}
/**
* Serializes an object into a byte array.
*
* @param object
* @return
*/
public static byte[] serialize(Object object) throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
try {
ObjectOutputStream serializer = new ObjectOutputStream(stream);
serializer.writeObject(object);
serializer.close();
} catch (IOException ex) {
Factory.handleException(ex);
}
byte[] result = stream.toByteArray();
stream.close();
return result;
}
private static void handleException(IOException ex) {
// TODO Auto-generated method stub
}
/**
* Merges the specified instance.
*
* @param obj
*/
public static void merge(DataObject obj) {
Factory.getSession().merge(obj);
}
/**
* Refreshes the specified instance.
*
* @param approval
*/
public static void refresh(DataObject obj) {
Factory.getSession().refresh(obj);
}
/**
* Saves or updates the object.
*
* @param obj
*/
public static void saveOrUpdate(DataObject obj) {
Factory.getSession().saveOrUpdate(obj);
}
/**
* Evicts the specified object from the session.
*
* @param obj
*/
public static void evict(DataObject obj) {
Factory.getSession().evict(obj);
}
/**
* Searches all available search sources (this is used for the back page only).
*
* @param search
* @return
*/
// public static PagedResults<Object> search(InternalSearchCriteria
// criteria, User user) {
// List<Class<?>> types = new ArrayList<Class<?>>();
// List<Object> result = new ArrayList<Object>();
// FullTextSession fullTextSession = Factory.getFullTextSession();
// List<InternalSearch> searches = InternalSearchFactory.getForUser(user);
// int totalRows = 0;
// BooleanQuery query = new BooleanQuery();
//
// // loop through each type
// for (InternalSearch search : searches) {
// try {
// // add the type
// BooleanQuery typeQuery = new BooleanQuery();
// typeQuery.add(new TermQuery(new Term(DocumentBuilder.CLASS_FIELDNAME,
// search.getResultType())), Occur.MUST);
//
// // add the fields
// String [] searchFields = search.getSearchFields().split(",");
// BooleanQuery subQuery = new BooleanQuery();
// for (String field : searchFields) {
// subQuery.add(new TermQuery(new Term(field, "(" +
// criteria.getText().toLowerCase() + ")")), Occur.SHOULD);
// }
//
// // apply the analyzer to the sub query
// try {
// String queryString = subQuery.toString();
// // typeQuery.add(new QueryParser(queryString, new
// StandardAnalyzer()).parse(queryString), Occur.MUST);
// typeQuery.add(new QueryParser(queryString, new
// WhitespaceAnalyzer()).parse(queryString), Occur.MUST);
// } catch (ParseException ex) {
// Factory.log.error("Could not parse query.", ex);
// }
//
// query.add(typeQuery, Occur.SHOULD);
//
// types.add(Class.forName(search.getResultType()));
// } catch (ClassNotFoundException ex) {
// Factory.log.error("Internal search class not found: " +
// search.getResultType() + " for search: " + search.getName(), ex);
// }
// }
//
// // run the query
// FullTextQuery searchQuery = fullTextSession.createFullTextQuery(query,
// types.toArray(new Class[0]));
// searchQuery.setFirstResult(criteria.getPageNumber() *
// criteria.getPageSize());
// searchQuery.setMaxResults(criteria.getPageSize());
// searchQuery.enableFullTextFilter("users").setParameter("user", user);
// searchQuery.enableFullTextFilter("documents").setParameter("user", user);
// searchQuery.enableFullTextFilter("accounts").setParameter("user", user);
// searchQuery.enableFullTextFilter("content").setParameter("user", user);
// Factory.log.debug("Search Query: " + query.toString());
//
// result = searchQuery.list();
// totalRows = searchQuery.getResultSize();
//
// return new PagedResults<Object>(result, totalRows);
// }
//
// /**
// * Searches a specific type.
// * @param criteria
// * @param type
// * @param user
// * @return
// */
// @SuppressWarnings("unchecked")
// public static PagedResults<Object> search(InternalSearchCriteria
// criteria, Class<?> type, User user) {
// FullTextSession fullTextSession = Factory.getFullTextSession();
// // get the internal search by the specified type
// InternalSearch search = InternalSearchFactory.getByType(type, user);
// List<Object> result = null;
// String [] queries = null;
// String [] fields = null;
// int totalRows = 0;
//
// if (search == null)
// return new PagedResults<Object>(new ArrayList<Object>(), 0);
//
// // get the fields
// fields = search.getSearchFields().split(",");
// queries = new String[fields.length];
//
// // build the array of term queries
// for (int index = 0; index < fields.length; index++) {
// // add the query
// queries[index] = criteria.getText();
// }
//
// // execute the search
// try {
// org.apache.lucene.search.Query query =
// MultiFieldQueryParser.parse(queries, fields, new StandardAnalyzer());
// FullTextQuery searchQuery = fullTextSession.createFullTextQuery(query,
// type);
// searchQuery.setFirstResult(criteria.getPageNumber() *
// criteria.getPageSize());
// searchQuery.setMaxResults(criteria.getPageSize());
// searchQuery.enableFullTextFilter("users").setParameter("user", user);
// searchQuery.enableFullTextFilter("documents").setParameter("user", user);
// searchQuery.enableFullTextFilter("accounts").setParameter("user", user);
// searchQuery.enableFullTextFilter("content").setParameter("user", user);
// Factory.log.debug("Search Query: " + query.toString());
//
// result = searchQuery.list();
// totalRows = searchQuery.getResultSize();
// } catch (ParseException e) {
// Factory.log.error("Could not parse search query", e);
// }
//
// return new PagedResults<Object>(result, totalRows);
// }
/**
* Creates a hibernate query.
*
* @param query
* @return
*/
public static Query createQuery(String query) {
return Factory.getSession().createQuery(query);
}
public static FullTextSession getFullTextSession() {
return Search.getFullTextSession(Factory.getSession());
}
/**
* Closes the session factory. Should only be called when an application is closing.
*/
public static void close() {
if (!isNoClose())
Factory.getFactory().close();
}
/**
* @param noCommit
* the noCommit to set
*/
public static void setNoCommit(boolean noCommit) {
Factory.noCommit = noCommit;
}
/**
* @return the noCommit
*/
public static boolean isNoCommit() {
return noCommit;
}
/**
* @param autoRollback
* the autoRollback to set
*/
public static void setAutoRollback(boolean autoRollback) {
Factory.autoRollback = autoRollback;
}
/**
* @return the autoRollback
*/
public static boolean isAutoRollback() {
return autoRollback;
}
/**
* @param noClose
* the noClose to set
*/
public static void setNoClose(boolean noClose) {
Factory.noClose = noClose;
}
/**
* @return the noClose
*/
public static boolean isNoClose() {
return noClose;
}
}

View File

@ -0,0 +1,83 @@
package com.usvisatrack.core.common;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.usvisatrack.core.common.search.InternalSearch;
import com.usvisatrack.core.dao.model.EntityListener;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import org.hibernate.criterion.Restrictions;
import org.hibernate.search.annotations.DateBridge;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Resolution;
import org.hibernate.search.annotations.Store;
public class InternalSearchFactory {
/**
* Gets a list of all internal searches.
*
* @return
*/
@SuppressWarnings("unchecked")
public static List<InternalSearch> getAll() {
return Factory.createCriteria(InternalSearch.class).list();
}
/**
* Gets an internal search by the specified id.
*
* @param id
* @return
*/
public static InternalSearch get(int id) {
return Factory.get(InternalSearch.class, id);
}
/**
* Saves the specified internal search.
*
* @param search
*/
public static void save(InternalSearch search) {
Factory.save(search);
}
/**
* Deletes the specified internal search.
*
* @param search
*/
public static void delete(InternalSearch search) {
Factory.delete(search);
}
/**
* Gets a list of searches available to the specified user.
*
* @param user
* @return
*/
@SuppressWarnings("unchecked")
/**
* Gets an internal search by name.
* @param name
* @return
*/
public static InternalSearch get(String name) {
return (InternalSearch) Factory.createCriteria(InternalSearch.class).add(Restrictions.eq("name", name)).setMaxResults(1)
.uniqueResult();
}
}

View File

@ -0,0 +1,25 @@
package com.usvisatrack.core.common;
/**
* UPCES Constant
*
* @author YuCheng Hu
*
*/
public final class USVisaTrackConstant {
public static final String CDN_URL = "https://cdn.upcex.com/";
public static final String APIDATA_FOLDER = "/home/bcodepot/apidata/";
public static final String SESSION_NAME_USER = "upcexUser";
public final static String CDN_FOLDER_ITEM_IMG = "/home/cdn/com-upcex/data/item/img";
public static enum ItemCodeStatus {
NORMAL, CHECK_DIGIT_ERROR, WEB_DATA_NOT_FOUND;
}
public static enum ItemCodeType {
SKU, ASIN, BBYSKU;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,11 @@
package com.usvisatrack.core.common.data;
/**
* DataCrawlStatus OBJ
*
* @author YuCheng Hu
*
*/
public enum DataCrawlStatus {
ACCEPTED, NOTUPC, BADUPC, DUPLICATEDUPC, NORESULTS
}

View File

@ -0,0 +1,46 @@
package com.usvisatrack.core.common.search;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author YuCheng Hu
*
*Represents a facet returned from the search back end. Facets have many values, and each value has a count of the number
* of results that have the facet value.
*/
public class Facet {
private List<FacetValue> values = new ArrayList<FacetValue>();
private String name = "";
private String displayName = "";
public Facet() {
}
public Facet(String name, String displayName) {
this.name = name;
this.displayName = displayName;
}
public List<FacetValue> getValues() {
return values;
}
public String getName() {
return name;
}
public String getDisplayName() {
return displayName;
}
public void addValue(FacetValue value) {
this.values.add(value);
}
public void setValues(List<FacetValue> values) {
this.values = values;
}
}

View File

@ -0,0 +1,34 @@
package com.usvisatrack.core.common.search;
/**
*
* @author YuCheng Hu
*
*/
public class FacetValue {
private String value = "";
private String displayValue = "";
private long count = 0;
public FacetValue() {
}
public FacetValue(String value, String displayValue, long count) {
this.value = value;
this.displayValue = displayValue;
this.count = count;
}
public String getValue() {
return value;
}
public long getCount() {
return count;
}
public String getDisplayValue() {
return displayValue;
}
}

View File

@ -0,0 +1,81 @@
package com.usvisatrack.core.common.search;
import com.usvisatrack.core.common.DataObject;
/**
*
* @author YuCheng Hu
*
*/
public class InternalSearch extends DataObject {
/**
*
*/
private static final long serialVersionUID = 1L;
private Long id = 0L;
private String name = "";
private String resultType = "";
private String searchFields = "";
/**
* @return the id
*/
public Long getId() {
return id;
}
/**
* @param id
* the id to set
*/
public void setId(Long id) {
this.id = id;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the resultType
*/
public String getResultType() {
return resultType;
}
/**
* @param resultType
* the resultType to set
*/
public void setResultType(String resultType) {
this.resultType = resultType;
}
/**
* @return the labelField
*/
public String getSearchFields() {
return searchFields;
}
/**
* @param labelField
* the labelField to set
*/
public void setSearchFields(String labelField) {
this.searchFields = labelField;
}
}

View File

@ -0,0 +1,60 @@
package com.usvisatrack.core.common.search;
public class InternalSearchCriteria {
private String text = "";
private int pageSize = 25;
private int pageNumber = 0;
public InternalSearchCriteria() {
}
public InternalSearchCriteria(String text) {
this.text = text;
}
/**
* @return the text
*/
public String getText() {
return text;
}
/**
* @param text
* the text to set
*/
public void setText(String text) {
this.text = text;
}
/**
* @return the pageSize
*/
public int getPageSize() {
return pageSize;
}
/**
* @param pageSize
* the pageSize to set
*/
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
/**
* @return the pageNumber
*/
public int getPageNumber() {
return pageNumber;
}
/**
* @param pageNumber
* the pageNumber to set
*/
public void setPageNumber(int pageNumber) {
this.pageNumber = pageNumber;
}
}

View File

@ -0,0 +1,21 @@
package com.usvisatrack.core.dao.model;
import java.util.Date;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import com.usvisatrack.core.common.DataObject;
public class EntityListener {
@PrePersist
public void prePersist(DataObject entity) {
entity.setCreateDate(new Date());
entity.setModifyDate(new Date());
}
@PreUpdate
public void preUpdate(DataObject entity) {
entity.setModifyDate(new Date());
}
}

View File

@ -0,0 +1,100 @@
package com.usvisatrack.core.dao.model;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.usvisatrack.core.common.DataObject;
/**
* Merchant generated by hbm2java
*/
public class User extends DataObject implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = -8094138967079219902L;
private String email;
private String userName;
private String password;
private String apiKey;
private String apiToken;
private String firstName;
private String lirstName;
private Date dateReg;
public User() {
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public String getApiToken() {
return apiToken;
}
public void setApiToken(String apiToken) {
this.apiToken = apiToken;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLirstName() {
return lirstName;
}
public void setLirstName(String lirstName) {
this.lirstName = lirstName;
}
public Date getDateReg() {
return dateReg;
}
public void setDateReg(Date dateReg) {
this.dateReg = dateReg;
}
}

View File

@ -0,0 +1,144 @@
package com.usvisatrack.core.dao.model;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.usvisatrack.core.common.DataObject;
import com.usvisatrack.core.common.USVisaTrackConstant.ItemCodeType;
/**
*
* @author YuCheng Hu
*
*/
public class Visa extends DataObject implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = -7563954515794041068L;
private List<String> upcList;
private String gtin;
private String itemCode;
private String itemName;
private String price;
private String itemDescription = null;
public Visa() {
}
/*
* (non-Javadoc)
*
* @see com.verani.common.DataObject#getId()
*/
public List<String> getUpcList() {
return upcList;
}
public String getGtin() {
return gtin;
}
public void setGtin(String gtin) {
this.gtin = gtin;
}
public void setUpcList(List<String> upcList) {
this.upcList = upcList;
}
public String getItemCode() {
return itemCode;
}
public void setItemCode(String itemCode) {
this.itemCode = itemCode;
}
public String getItemName() {
return itemName;
}
public void setItemName(String itemName) {
this.itemName = itemName;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
// public List<ItemPrice> getItemPrices() {
// return itemPrices;
// }
//
// public void setItemPrices(List<ItemPrice> itemPrices) {
// this.itemPrices = itemPrices;
// }
public String getItemDescription() {
return itemDescription;
}
public void setItemDescription(String itemDescription) {
this.itemDescription = itemDescription;
}
public void updateItemCode(ItemCodeType itemCodeType, String itemCodeValue) {
Map<String, String> itemCodeMap = new HashMap<>();
if (StringUtils.isBlank(this.itemCode)) {
itemCodeMap.put(ItemCodeType.SKU.name(), "");
itemCodeMap.put(ItemCodeType.ASIN.name(), "");
itemCodeMap.put(ItemCodeType.BBYSKU.name(), "");
} else {
Gson gson = new Gson();
Type stringStringMap = new TypeToken<Map<String, String>>() {
}.getType();
itemCodeMap = gson.fromJson(this.itemCode, stringStringMap);
}
itemCodeMap.put(itemCodeType.name(), itemCodeValue);
this.itemCode = new Gson().toJson(itemCodeMap);
}
// public List<ItemPriceWeb> getItemPriceWebList() {
// return itemPriceWebList;
// }
//
// public void setItemPriceWebList(List<ItemPriceWeb> itemPriceWebList) {
// this.itemPriceWebList = itemPriceWebList;
// }
// public ItemNutrition getItemNutrition() {
// return itemNutrition;
// }
//
// public void setItemNutrition(ItemNutrition itemNutrition) {
// this.itemNutrition = itemNutrition;
// }
}

View File

@ -0,0 +1,22 @@
package com.usvisatrack.core.factories;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
import org.hibernate.type.LongType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ConfFactory {
private static final int LISTING_PAGE_SIZE = 20;
public static final int DEFAULT_AUTH_EXPIRATION = 10;
private static Logger logger = LoggerFactory.getLogger(ConfFactory.class);
}

View File

@ -0,0 +1,18 @@
package com.usvisatrack.core.factories;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
*
* @author YuCheng Hu
*
*/
public class DataFactory {
// private static final int LISTING_PAGE_SIZE = 20;
public static final int DEFAULT_AUTH_EXPIRATION = 10;
private static Logger logger = LoggerFactory.getLogger(DataFactory.class);
}

View File

@ -0,0 +1,22 @@
package com.usvisatrack.core.factories;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.usvisatrack.core.common.Factory;
/**
* Item Data Factory
*
* @author YuCheng Hu
*
*/
public class LogFactory extends Factory {
private static final int LISTING_PAGE_SIZE = 20;
public static final int DEFAULT_AUTH_EXPIRATION = 10;
private static Logger logger = LoggerFactory.getLogger(LogFactory.class);
}

View File

@ -0,0 +1,23 @@
package com.usvisatrack.core.factories;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Transaction;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.usvisatrack.core.common.Factory;
public class UserFactory {
private static final int LISTING_PAGE_SIZE = 20;
public static final int DEFAULT_AUTH_EXPIRATION = 10;
private static Logger logger = LoggerFactory.getLogger(UserFactory.class);
}

View File

@ -0,0 +1,32 @@
package com.usvisatrack.core.factories;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Transaction;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.usvisatrack.core.common.Factory;
/**
* Item Data Factory
*
* @author YuCheng Hu
*
*/
public class VisaFactory extends Factory {
private static final int LISTING_PAGE_SIZE = 20;
public static final int DEFAULT_AUTH_EXPIRATION = 10;
private static Logger logger = LoggerFactory.getLogger(VisaFactory.class);
}

View File

@ -0,0 +1,23 @@
package com.usvisatrack.core.service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Item Service
*
* @author YuCheng Hu
*
*/
public class ItemCodeService {
private static final Logger logger = LoggerFactory.getLogger(ItemCodeService.class);
}

View File

@ -0,0 +1,24 @@
package com.usvisatrack.core.service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Item Service
*
* @author YuCheng Hu
*
*/
public class ItemImageService {
private static final Logger logger = LoggerFactory.getLogger(ItemImageService.class);
}

View File

@ -0,0 +1,23 @@
package com.usvisatrack.core.service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Item Service
*
* @author YuCheng Hu
*
*/
public class ItemService {
private static final Logger logger = LoggerFactory.getLogger(ItemService.class);
}

View File

@ -0,0 +1,77 @@
package com.usvisatrack.core.utils;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.collections.ListUtils;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.commons.math3.util.Precision;
import org.apache.http.client.ClientProtocolException;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.Namespace;
import org.jdom2.filter.Filters;
import org.jdom2.input.SAXBuilder;
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;
import org.jdom2.xpath.XPathExpression;
import org.jdom2.xpath.XPathFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableSet;
import com.google.gson.Gson;
/**
* BcoDepot Amazon Utils class
*
* @author YuCheng Hu
*
*/
public final class AmazonUtils {
private static final Logger logger = LoggerFactory.getLogger(AmazonUtils.class);
// private static String APIDATA_CDN_FOLDER = "/home/cdn/com-bcodepot-www/data/apidata";
private static String AWS_ACCESS_KEY_ID = "";
private static String AWS_SECRET_KEY = "";
private static String ENDPOINT = "ecs.amazonaws.com";
private static String AWS_NAME = "AmazonMerchandiseData";
private static String AMAZON_NAME = "Amazon";
public final static String CACHE_DATA_FOLDER = "/home/bcodepot/cache";
public final static String API_DATA_FOLDER = "/home/bcodepot/api";
public final static String CDN_DATA_FOLDER = "/home/cdn/com-bcodepot-www/data/item";
public final static String ITEM_ATTACHMENT_CACHE_FOLDER = "/home/bcodepot/cache/" + AMAZON_NAME;
public final static String ITEM_ATTACHMENT_CDN_FOLDER = "/home/cdn/com-bcodepot-www/data/item";
public final static Date C_DATE = new Date();
private static final Namespace AMAZON_NAMESPACE = Namespace.getNamespace("Amazon",
"http://webservices.amazon.com/AWSECommerceService/2011-08-01");
}

View File

@ -0,0 +1,37 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.usvisatrack.core.dao.model">
<class name="User" table="user" catalog="ntc_usvisatrack">
<id name="id" type="java.lang.Long">
<column name="uid" />
<generator class="identity" />
</id>
<property name="email" type="string">
<column name="email" />
</property>
<property name="userName" type="string">
<column name="username" />
</property>
<property name="password" type="string">
<column name="password" />
</property>
<property name="apiKey" type="string">
<column name="api_key" />
</property>
<property name="apiToken" type="string">
<column name="api_token" />
</property>
<property name="dateReg" type="timestamp">
<column name="date_reg" />
</property>
</class>
</hibernate-mapping>

View File

@ -0,0 +1,44 @@
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.usvisatrack.core.dao.model">
<class name="Visa" table="visa" catalog="ntc_usvisatrack">
<id name="id" type="java.lang.Long">
<column name="item_id" />
<generator class="identity" />
</id>
<property name="gtin" type="string">
<column name="gtin" length="16" />
</property>
<property name="itemCode" type="string">
<column name="item_code" />
</property>
<property name="itemName" type="string">
<column name="item_name" />
</property>
<property name="price" type="string">
<column name="price" precision="20" scale="6" />
</property>
<property name="itemDescription" type="string">
<column name="description" />
</property>
<property name="createDate" type="timestamp">
<column name="date_add" length="19" />
</property>
<property name="modifyDate" type="timestamp">
<column name="date_upd" length="19" />
</property>
</class>
</hibernate-mapping>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> -->
<!-- <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property> -->
<!-- <property name="hibernate.connection.url">jdbc:mysql://yucheng-server/</property> -->
<!-- <property name="hibernate.connection.username">bcodepot</property> -->
<!-- <property name="hibernate.connection.password">123456</property> -->
<property name="hibernate.connection.pool.size">20</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="hibernate.jdbc.batch_size">20</property>
<property name="hibernate.current_session_context_class">thread</property>
<!--<property name="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</property> <property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property> -->
<!-- C3P0 -->
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.EhCacheProvider</property>
<property name="hibernate.c3p0.acquire_increment">1</property>
<property name="hibernate.c3p0.idleConnectionTestPeriod">30</property>
<property name="hibernate.c3p0.timeout">30</property>
<property name="hibernate.c3p0.max_statements">0</property>
<property name="hibernate.c3p0.max_size">100</property>
<property name="hibernate.c3p0.min_size">6</property>
<!-- <property name="hibernate.c3p0.testConnectionOnCheckin">true</property> -->
<property name="hibernate.c3p0.preferredTestQuery">SELECT 1</property>
<property name="hibernate.c3p0.validate">true</property>
<!-- HBMs -->
<mapping resource="hbm/User.hbm.xml" />
<mapping resource="hbm/Visa.hbm.xml" />
</session-factory>
</hibernate-configuration>

View File

@ -0,0 +1,41 @@
# - ------------------------------------------------------------------------------------------------
# - L O G L E V E L
# - ------------------------------------------------------------------------------------------------
log4j.logger.org.hibernate=WARN,production,console
log4j.logger.com.upcex=INFO,production,console
log4j.logger.com.mchange=WARN,production,console
# - ------------------------------------------------------------------------------------------------
# - S E R V E R S T A T U S C H E C K A P P E N D E R
# - ------------------------------------------------------------------------------------------------
log4j.appender.ServerStatusCheck=org.apache.log4j.RollingFileAppender
log4j.appender.ServerStatusCheck.encoding=UTF-8
log4j.appender.ServerStatusCheck.Threshold=INFO
log4j.appender.ServerStatusCheck.File=/home/bcodepot/logs/services/serverstatuscheck/serverstatuscheck.log
log4j.appender.ServerStatusCheck.MaxFileSize=200MB
log4j.appender.ServerStatusCheck.MaxBackupIndex=7
log4j.appender.ServerStatusCheck.layout=org.apache.log4j.PatternLayout
log4j.appender.ServerStatusCheck.layout.ConversionPattern=%-d{yyyy/MM/dd HH:mm:ss} %-5p [%c] - %m%n
# - ------------------------------------------------------------------------------------------------
# - P R O D U C T I O N E N V I R O N M E N T A P P E N D E R
# - ------------------------------------------------------------------------------------------------
log4j.appender.production=org.apache.log4j.RollingFileAppender
log4j.appender.production.encoding=UTF-8
log4j.appender.production.Threshold=INFO
log4j.appender.production.File=/home/bcodepot/logs/services/services.log
log4j.appender.production.MaxFileSize=200MB
log4j.appender.production.MaxBackupIndex=7
log4j.appender.production.layout=org.apache.log4j.PatternLayout
log4j.appender.production.layout.ConversionPattern=%-d{yyyy/MM/dd HH:mm:ss} %-5p [%c] - %m%n
# - ------------------------------------------------------------------------------------------------
# - C O N S O L E A P P E N D E R
# - ------------------------------------------------------------------------------------------------
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.target=System.out
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.Threshold=INFO
log4j.appender.console.layout.ConversionPattern=%-d{yyyy/MM/dd HH:mm:ss} %-5p [%c] - %m%n

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE RelativeLayout>
<Configuration status="WARN">
<Appenders>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- C O N S O L E - A P P E N D E R -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%-d{yyyy/MM/dd HH:mm:ss} %-5p [%c] - %m%n" />
<ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY" />
</Console>
</Appenders>
<Loggers>
<root level="DEBUG">
<appender-ref ref="Console" />
</root>
</Loggers>
</Configuration>

View File

@ -0,0 +1,57 @@
/*
* Licensed to the Apache Software Foundation (ASF).
*/
package com.usvisatrack.core.test;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import com.usvisatrack.core.common.Factory;
/**
*
* @author YuCheng Hu
*
*/
public class CloudTest extends TestCase {
@Before
@Override
protected void setUp() throws Exception {
Factory.beginTransaction();
}
@After
@Override
protected void tearDown() throws Exception {
Factory.rollbackTransaction();
}
// @Test
// public void testUploadFolder() {
// try {
// CloudFiles.uploadDirectoryContentsToCloud("d:\\CDN\\Cloud2", "production-logs");
//
// } catch (Exception ex) {
// Factory.rollbackTransaction();
// ex.printStackTrace();
// Assert.fail();
// }
// }
// @Test
// public void testGetFile() {
// try {
// CloudFiles.getCDNSearchSerializeObj();
//
// } catch (Exception ex) {
// Factory.rollbackTransaction();
// ex.printStackTrace();
//// Assert.fail();
// }
// }
}

View File

@ -0,0 +1,58 @@
/*
* Licensed to the Apache Software Foundation (ASF).
*/
package com.usvisatrack.core.test;
import java.util.List;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author YuCheng Hu
*
*/
public class VisaTest extends TestCase {
private final static Logger logger = LoggerFactory.getLogger(VisaTest.class);
@Test
public void testItemByGTIN() throws Exception {
// String gtin = "6902253867314";
// ItemCode itemCode = ItemFactory.getItemCodeByGTIN(gtin);
//
// logger.debug("Item Name {}", itemCode.getItem().getName());
// logger.debug("attachment Size {}", itemCode.getItem().getItemAttachments().size());
// logger.debug("Price Size {}", itemCode.getItem().getItemPrices().size());
// logger.debug("Accese URL {}", itemCode.getItem().getItemPrices().get(0).getAccessURL());
// List<ItemPrice> itemPriceList = ItemFactory.getNewestItemPriceList(394L);
// logger.debug("Accese URL {}", itemPriceList.size());
}
@Test
public void testDealsSave() throws Exception {
}
@Before
@Override
protected void setUp() throws Exception {
}
@After
@Override
protected void tearDown() throws Exception {
}
}

View File

@ -0,0 +1,14 @@
# JDBC Connection
hibernate.connection.driver_class=com.mysql.jdbc.Driver
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.connection.url=jdbc:mysql://db.upcex.com/
# Username and Password
hibernate.connection.username=upcex.web
hibernate.connection.password=026l64e4rtfg
# Performance
#hibernate.connection.pool.size=20
#hibernate.connection.autocommit=true
#hibernate.jdbc.batch_size=20
#hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE RelativeLayout>
<Configuration status="WARN">
<Appenders>
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- C O N S O L E - A P P E N D E R -->
<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%-d{yyyy/MM/dd HH:mm:ss} %-5p [%c] - %m%n" />
<ThresholdFilter level="DEBUG" onMatch="ACCEPT" onMismatch="DENY" />
</Console>
</Appenders>
<Loggers>
<root level="DEBUG">
<appender-ref ref="Console" />
</root>
</Loggers>
</Configuration>