This commit is contained in:
coderfengyun 2014-01-06 17:10:44 +08:00
parent 1d4fcbcb50
commit 90940286d4
6 changed files with 66 additions and 29 deletions

View File

@ -49,7 +49,7 @@ public class RunningAgentService {
return (RunScenarioResultModel) MarshalHelper.unmarshal(
RunScenarioResultModel.class, httpResponse.getContent());
} catch (JAXBException e) {
logger.error(ExceptionLog.getExceptionStackTrace(e));
logger.error(ExceptionLog.getStackTrace(e));
return null;
}
@ -113,7 +113,7 @@ public class RunningAgentService {
return (AgentBehaviorsBriefModel) MarshalHelper.unmarshal(
AgentBehaviorsBriefModel.class, httpResponse.getContent());
} catch (Exception e) {
logger.error(ExceptionLog.getExceptionStackTrace(e)
logger.error(ExceptionLog.getStackTrace(e)
+ " When behaviorsBrief");
return null;
}
@ -131,10 +131,10 @@ public class RunningAgentService {
return (AgentPageBriefModel) MarshalHelper.unmarshal(
AgentPageBriefModel.class, httpResponse.getContent());
} catch (IOException e) {
logger.error(ExceptionLog.getExceptionStackTrace(e));
logger.error(ExceptionLog.getStackTrace(e));
return null;
} catch (JAXBException e) {
logger.error(ExceptionLog.getExceptionStackTrace(e));
logger.error(ExceptionLog.getStackTrace(e));
return null;
}
}
@ -151,10 +151,10 @@ public class RunningAgentService {
return (AgentPagesBriefModel) MarshalHelper.unmarshal(
AgentPagesBriefModel.class, httpResponse.getContent());
} catch (IOException e) {
logger.error(ExceptionLog.getExceptionStackTrace(e));
logger.error(ExceptionLog.getStackTrace(e));
return null;
} catch (JAXBException e) {
logger.error(ExceptionLog.getExceptionStackTrace(e));
logger.error(ExceptionLog.getStackTrace(e));
return null;
}

View File

@ -58,7 +58,7 @@ public class ScriptService {
return ret;
} catch (Exception e) {
logger.info("Exception when save script to DB" + scriptContent
+ " : " + ExceptionLog.getExceptionStackTrace(e));
+ " : " + ExceptionLog.getStackTrace(e));
transaction.rollback();
return null;
} finally {
@ -171,7 +171,7 @@ public class ScriptService {
return (RunScenarioModel) MarshalHelper.unmarshal(
RunScenarioModel.class, content);
} catch (JAXBException e) {
logger.error(ExceptionLog.getExceptionStackTrace(e));
logger.error(ExceptionLog.getStackTrace(e));
return null;
}
}

View File

@ -72,11 +72,11 @@ public class TestPlanScriptResultService {
getSpecificFieldValue(briefModel, fieldName),
result.getCreateDatetime()));
} catch (JAXBException e) {
logger.info(ExceptionLog.getExceptionStackTrace(e)
logger.info(ExceptionLog.getStackTrace(e)
+ " When unmarshal the model from ResultCOntent");
continue;
} catch (NoSuchFieldException e) {
logger.info(ExceptionLog.getExceptionStackTrace(e)
logger.info(ExceptionLog.getStackTrace(e)
+ " When get Field from the model from ResultCOntent");
continue;
}
@ -115,7 +115,7 @@ public class TestPlanScriptResultService {
testPlanScriptResult.getResultContent()));
}
} catch (Exception e) {
logger.error(ExceptionLog.getExceptionStackTrace(e));
logger.error(ExceptionLog.getStackTrace(e));
}
return result;
}
@ -147,7 +147,7 @@ public class TestPlanScriptResultService {
ScriptBehaviorsBriefModel.class,
testPlanScriptResult.getResultContent());
} catch (Exception e) {
logger.error(ExceptionLog.getExceptionStackTrace(e));
logger.error(ExceptionLog.getStackTrace(e));
}
return new ScriptBehaviorsBriefModel();
}
@ -176,7 +176,7 @@ public class TestPlanScriptResultService {
ScriptPagesBriefModel.class,
testPlanScriptResult.getResultContent());
} catch (Exception e) {
logger.error(ExceptionLog.getExceptionStackTrace(e));
logger.error(ExceptionLog.getStackTrace(e));
}
return result;
}

View File

@ -23,7 +23,7 @@ import org.bench4q.share.models.master.statistics.ScriptBehaviorsBriefModel;
import org.bench4q.share.models.master.statistics.ScriptBriefResultModel;
import org.bench4q.share.models.master.statistics.ScriptPageBriefModel;
import org.bench4q.share.models.master.statistics.ScriptPagesBriefModel;
import org.bench4q.share.models.master.statistics.StatisticsResultModel;
import org.bench4q.share.models.master.statistics.SampleModel;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions;
@ -172,7 +172,7 @@ public class TestPlanScriptService implements Observer {
model));
result.setResultType(model.getClass().getName());
} catch (JAXBException e) {
logger.error(ExceptionLog.getExceptionStackTrace(e));
logger.error(ExceptionLog.getStackTrace(e));
result.setResultContent("");
}
result.setCreateDatetime(createDatetime);
@ -235,6 +235,6 @@ public class TestPlanScriptService implements Observer {
RunningScript runningScript = (RunningScript) o;
this.doSaveResult(runningScript.getTestPlanID(),
runningScript.getScriptId(), arg,
((StatisticsResultModel) arg).getSamplingTime());
((SampleModel) arg).getSamplingTime());
}
}

View File

@ -81,7 +81,7 @@ public class TestPlanService {
return true;
} catch (Exception e) {
transaction.rollback();
logger.error(ExceptionLog.getExceptionStackTrace(e));
logger.error(ExceptionLog.getStackTrace(e));
return false;
} finally {
if (session != null) {

View File

@ -1,6 +1,15 @@
package org.bench4q.master.service.infrastructure;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import org.apache.log4j.Logger;
import org.bench4q.master.entity.TestPlanDB;
import org.bench4q.master.entity.User;
import org.bench4q.master.exception.ExceptionLog;
import org.bench4q.master.helper.CollectionHelper;
import org.bench4q.master.helper.HashHelper;
import org.bench4q.master.helper.SessionHelper;
import org.hibernate.Session;
@ -15,6 +24,7 @@ public class UserService {
private HashHelper hashHelper;
public static byte NORAML_AUTHENTICATION = 0;
public static byte SUPER_AUTHENTICATION = 1;
private static Logger logger = Logger.getLogger(UserService.class);
private SessionHelper getSessionHelper() {
return sessionHelper;
@ -55,9 +65,7 @@ public class UserService {
transaction.rollback();
return false;
} finally {
if (session != null) {
session.close();
}
releaseSession(session);
}
}
@ -77,9 +85,7 @@ public class UserService {
e.printStackTrace();
return false;
} finally {
if (session != null) {
session.close();
}
releaseSession(session);
}
}
@ -96,9 +102,7 @@ public class UserService {
e.printStackTrace();
return null;
} finally {
if (session != null) {
session.close();
}
releaseSession(session);
}
}
@ -110,9 +114,42 @@ public class UserService {
e.printStackTrace();
return null;
} finally {
if (session != null) {
session.close();
}
releaseSession(session);
}
}
public List<TestPlanDB> querytestPlans(int userId) {
Session session = this.getSessionHelper().openSession();
try {
User user = (User) session.get(User.class, userId);
logger.info("User's testPlan count is "
+ user.getTestPlans().size());
return Collections.unmodifiableList(user.getTestPlans());
} catch (Exception e) {
logger.error(ExceptionLog.getStackTrace(e));
} finally {
releaseSession(session);
}
return new ArrayList<TestPlanDB>();
}
public TestPlanDB queryTestPlan(int userId, UUID testPlanRunId) {
Session session = this.getSessionHelper().openSession();
try {
return CollectionHelper.tryGetItemById(
((User) session.get(User.class, userId)).getTestPlans(),
testPlanRunId);
} catch (Exception e) {
logger.error(ExceptionLog.getStackTrace(e));
} finally {
releaseSession(session);
}
return null;
}
private void releaseSession(Session session) {
if (session != null) {
session.close();
}
}
}