import java.io.InputStream;
import java.io.PrintWriter;
import java.util.logging.Level;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.openntf.domino.xsp.XspOpenLogUtil;
import com.ibm.domino.services.ServiceException;
import com.ibm.domino.services.rest.RestServiceEngine;
import com.ibm.xsp.extlib.component.rest.CustomService;
import com.ibm.xsp.extlib.component.rest.CustomServiceBean;
public class BatchCheckService extends CustomServiceBean {
private final String classID="::"
+ new Throwable().getStackTrace()[0].getClassName() + "::";
@Override
public void renderService(CustomService service, RestServiceEngine engine) throws ServiceException {
try {
Throwable throwable = new Throwable();
super.renderService(service, engine);
HttpServletRequest request = engine.getHttpRequest();
HttpServletResponse response = engine.getHttpResponse();
PrintWriter writer = response.getWriter();
//JsonJavaObject jo = new JsonJavaObject();
boolean exists=request.getParameter("exists")!=null;
//System.out.println("id length: "+id.length());
BatchChecker obj=new BatchChecker();
response.setHeader("Content-Type", "application/json; charset=UTF-8");
writer.write("{\"body\": \"");
if(request.getContentType()!=null && request.getContentType().contains(
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
)
){
//String ext=MIMEType.getKey(request.getContentType());
InputStream bodyIs=request.getInputStream();
XspOpenLogUtil.logEvent(throwable, this.classID
+ throwable.getStackTrace()[1].getMethodName()+"(): "
+"Content-Type: "+request.getContentType(), Level.INFO,
null);
response.setHeader("Content-Type", "application/json; charset=UTF-8");
if (exists){
XspOpenLogUtil.logEvent(throwable, this.classID
+ throwable.getStackTrace()[1].getMethodName()+"(): "
+"list for batches are existing", Level.INFO,
null);
}else{
XspOpenLogUtil.logEvent(throwable, this.classID
+ throwable.getStackTrace()[1].getMethodName()+"(): "
+"list for batches are absent", Level.INFO,
null);
//obj.testCheckingOut(writer);
}
obj.checking(bodyIs, writer, exists);
}else //if(request.getContentType().contains("application/json"))
{
obj.testCheckingOut(writer);
}
writer.write("\"}");
writer.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
XspOpenLogUtil.logError(e);
}
}
}