litesoft
@ 25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
package org.litesoft.GWT.server; import org.litesoft.GWT.shared.service.*; import org.litesoft.core.util.*; import org.litesoft.testplan.*; import org.litesoft.util.*; import com.google.gwt.user.server.rpc.*; public class TestPlanServlet extends RemoteServiceServlet implements TestPlanService { private TestPlan mTestPlan = new TestPlan(); @Override public TestPlanStepResponse get( TestPlanStepRequest pRequest ) { if ( pRequest != null ) { int zStep = pRequest.getStep(); TestPlanStep[] zSteps = mTestPlan.getSteps(); if ( zStep < 0 ) { throw new RuntimeException( "Negative Steps (" + zStep + ") are not supported" ); } int zPrev = zStep - 1; if ( (0 <= zPrev) && (zPrev < zSteps.length) ) { TestPlanStep zPrevStep = deNull( zSteps[zPrev] ); String zFrom = UtilsCommon.noEmpty( zPrevStep.getFrom() ); String zTo = UtilsCommon.noEmpty( zPrevStep.getTo() ); if ( (zFrom != null) && (zTo != null) ) { DirectoryUtils.moveAllFiles( zFrom, zTo ); } } if ( zStep < zSteps.length ) { TestPlanStep zCurStep = deNull( zSteps[zStep] ); int zNext = zStep + 1; TestPlanStep zNextStep = deNull( (zNext < zSteps.length) ? zSteps[zNext] : null ); return new TestPlanStepResponse( zCurStep.getAction(), // zCurStep.getNumber(), zCurStep.getSection(), zCurStep.getPostText(), // zNextStep.getNumber(), zNextStep.getSection(), zNextStep.getPreText() ); } RuntimeException ex = new RuntimeException( "No More Steps, Requested Step " + zStep + " of " + (zSteps.length - 1) ); ex.printStackTrace(); throw ex; } return null; } private TestPlanStep deNull( TestPlanStep zStep ) { return (zStep != null) ? zStep : new TestPlanStep( null, "", null, null, null ); } } |