java - Google Cloud Print sometimes gives false errors -
i have java application uses google cloud print api (https://github.com/jittagornp/googlecloudprint) print pdf's. in cases works charm every , (approx 1 out of 100) gives error looks "det går inte att göra ändringar ett avslutat jobb". translated english reads: "can't make changes finished job" kicker pages prints every time, or without error.
code looks every call gcp:
public static submitjobresponse submitprintjob(string filename, string type){ string jsonticket; string printerid; submitjobresponse response = null; string jobtitle; jobtitle = filename.substring(filename.lastindexof('/') + 1); // login gcp googlecloudprint cloudprint = gcplogin(); jsonticket = "{'version':'1.0','print':{'vendor_ticket_item':[],'color':{'type':1},'copies':{'copies':4}}}"; printerid = session("printerlabel"); try { // file byte array path path = paths.get(filename); byte[] content = files.readallbytes(path); gson gson = new gson(); ticket ticket = gson.fromjson(jsonticket, ticket.class); string json = gson.tojson(ticket); //create job submitjob submitjob = new submitjob(); submitjob.setcontent(content); submitjob.setcontenttype("application/pdf"); submitjob.setprinterid(printerid); submitjob.setticket(ticket); submitjob.settitle(jobtitle); //send job response = cloudprint.submitjob(submitjob); logger.debug("printerid => {}", printerid); logger.debug("submit job response => {}", response.issuccess() + "," + response.getmessage()); if(response.issuccess()) { logger.debug("submit job id => {}", response.getjob().getid()); } cloudprint.disconnect(); } catch (exception ex) { logger.warn(null, ex); } return response; }
the api uses call "/submit?output=json&printerid=" @ gcp why i'm trying change finished job - i'm not submitting job id - printer id.
how rid of these false errors?
Comments
Post a Comment