Re: Issue with Range
3980273410 is the size of the file that i'm trying to transfer. actually its the index of the last byte of the file. all of my variables are declared as long -- the catalina stack trace shows: at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) at java.lang.Integer.parseInt(Integer.java:461) at java.lang.Integer.parseInt(Integer.java:499) at org.restlet.engine.http.header.RangeReader.update(RangeReader.java:65) so i guess i'll have to do more to manage a restarted transfer. thx. -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/Issue-with-Range-tp6379547p6382416.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2741410
Issue with Range
I'm using Directory to share files, but i would also like to allow aborted transfers to restart. Both server and client are Restlet implementations that rely on streams for the transfer. I added Range to the ClientResource and started to get the message: Internal Connector Error (1002) - For input string: 3980273410. When i look at catalina.log, i see java.lang.NumberFormatException: For input string: 3980273410. So, i'm guessing that i can't use -1 as the Range size? so the following is goofy? ClientResource resource = new ClientResource(restRequest); resource.getRanges().add(new Range(range, Range.SIZE_MAX)); -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/Issue-with-Range-tp6379547p6379547.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2740795
Re: Re: FileUpload extension: multipart/form-data support broken in RC1/RC2
The snapshot with the revised file upload works nicely on my system. thx for the fix. -- View this message in context: http://n2.nabble.com/FileUpload-extension-multipart-form-data-support-broken-in-RC1-RC2-tp4833848p4860663.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2502844
Re: Upload to Directory 2.0m6
Thought I'd contribute this variation on the example from M.Abdel-Aziz (thanks so much for the inspiration). It was written using 2.0m6. There are 3 code fragments: 1. the routing, 2. a file upload ServerResource, 3. code that inserts the uploaded file and its name (as specified in the URI) into a blob in a mysql database table. There are a couple more notes at the end. // 1. file upload routing in a Restlet Application Router router = new Router(getContext()); router.setDefaultMatchingMode(Template.MODE_STARTS_WITH); router.setRoutingMode(Router.MODE_BEST_MATCH); Router uploadRouter = new Router(getContext()); uploadRouter.attach(, FileUploadResource.class); uploadRouter.attach(/name/{name}, FileUploadResource.class); final ChallengeAuthenticator uploadGuard = new ChallengeAuthenticator(this.getContext(), ChallengeScheme.HTTP_BASIC, Restful Access -- Please supply your credentials); uploadGuard.setVerifier(myVerifier); uploadGuard.setNext(uploadRouter); router.attach(/fileuploads,uploadGuard); /** * 2. Resource that manages uploading files. * Sample curl used to test this beast: * * curl -v -u name:password http://127.0.0.1/myResource/fileuploads/name/test.jar -F name=@/Users/ty/Desktop/test.xml -X POST * */ public class FileUploadResource extends ServerResource { private static Logger myLog = Logger.getLogger(FileUploadResource.class); private Request request; private String fileName = ; private CMInfo cmi = null; @Override protected void doInit() throws ResourceException { getVariants().add(new Variant(MediaType.MULTIPART_ALL)); request = getRequest(); ClientInfo cli = request.getClientInfo(); ChallengeResponse cr = request.getChallengeResponse(); cmi = new CMInfo(cr.getIdentifier(), cli.getAddress(), null); fileName = (String) getRequest().getAttributes().get(name); if(request.getMethod() != org.restlet.data.Method.POST) { setStatus(Status.CLIENT_ERROR_CONFLICT); } else { setStatus(Status.SUCCESS_OK); } } @Post public void uploadIt(Representation file) { try { FileItemFactory factory = new DiskFileItemFactory(); RestletFileUpload fileUpload = new RestletFileUpload(factory); FileItemIterator iter = fileUpload.getItemIterator(file); if (iter.hasNext()) { FileItemStream item = iter.next(); if (!item.isFormField()) { myLog.info(ContentType:+item.getContentType()); myLog.info(file:+item.getName()); Attachment.uploadAttachment(cmi, item.openStream(), fileName); } } } catch (Exception e) { myLog.info(uploadIt exception:+e); } setStatus(Status.SUCCESS_CREATED); // assume works for now } } // 3. a function to save an uploaded file to a mySql attachments table public static int uploadAttachment(CMInfo cmi, InputStream inStream, String attachmentName) { InputStream is = null; int attachmentId = -1; DataSource ds = MyUtils.getDataSource(); java.sql.Connection conn = null; PreparedStatement ps = null; String sqlString = null; int fileLength = 0; try { fileLength = (int) inStream.available(); if(StringUtils.isNotBlank(attachmentName)) { sqlString = INSERT INTO attachments (filename, contents) VALUES(?, ?) ; conn = ds.getConnection(); ps = StatementFactory.getStatement(conn, sqlString, cmi); ps.setString(1, attachmentName); ps.setBinaryStream(2, inStream, fileLength); ps.executeUpdate(); sqlString = SELECT LAST_INSERT_ID() as autoId ; ps = StatementFactory.getStatement(conn, sqlString, cmi); ResultSet rs = ps.executeQuery(); if (rs.next()) {
json stack overflow
i'm seeing a stack overflow error in catalina.log when i try to return a json rep of a resource with 20 fields. same code worked perfectly a month ago, so i'm wondering if anyone else has seen the problem. I'm attaching the code and stack trace. I'm running 2.0m5 on osx 10.6.1. @Get(json) public Representation toJSOn() { Representation representation = null; try { representation = new JsonRepresentation(this.computer); } catch (Exception e) { myLog.info(toJSOn Exception:+e); } return representation; } INFO: 2009-10-1909:46:45127.0.0.1 - 127.0.0.1 9006GET /MyResource/computers/name/Tom - 500 365 - 652 http://127.0.0.1:9006 Restlet-Framework/2.0m5 - Oct 19, 2009 9:56:45 AM org.restlet.ext.httpclient.HttpClientHelper start INFO: Starting the HTTP client Oct 19, 2009 9:56:45 AM org.restlet.resource.UniformResource doCatch INFO: Exception or error caught in resource org.restlet.resource.ResourceException: The server encountered an unexpected condition which prevented it from fulfilling the request at org.restlet.resource.ServerResource.doHandle(ServerResource.java:484) at org.restlet.resource.ServerResource.get(ServerResource.java:637) at org.restlet.resource.ServerResource.doHandle(ServerResource.java:517) at org.restlet.resource.ServerResource.doNegotiatedHandle(ServerResource.java:577) at org.restlet.resource.ServerResource.doConditionalHandle(ServerResource.java:260) at org.restlet.resource.ServerResource.handle(ServerResource.java:844) at org.restlet.resource.Finder.handle(Finder.java:523) at org.restlet.routing.Filter.doHandle(Filter.java:156) at org.restlet.routing.Filter.handle(Filter.java:201) at org.restlet.routing.Router.doHandle(Router.java:320) at org.restlet.routing.Router.handle(Router.java:519) at org.restlet.routing.Filter.doHandle(Filter.java:156) at org.restlet.routing.Filter.handle(Filter.java:201) at org.restlet.routing.Filter.doHandle(Filter.java:156) at org.restlet.routing.Filter.handle(Filter.java:201) at org.restlet.routing.Router.doHandle(Router.java:320) at org.restlet.routing.Router.handle(Router.java:519) at org.restlet.routing.Filter.doHandle(Filter.java:156) at org.restlet.routing.Filter.handle(Filter.java:201) at org.restlet.routing.Filter.doHandle(Filter.java:156) at org.restlet.routing.Filter.handle(Filter.java:201) at org.restlet.routing.Filter.doHandle(Filter.java:156) at org.restlet.engine.application.StatusFilter.doHandle(StatusFilter.java:152) at org.restlet.routing.Filter.handle(Filter.java:201) at org.restlet.routing.Filter.doHandle(Filter.java:156) at org.restlet.routing.Filter.handle(Filter.java:201) at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111) at org.restlet.engine.application.ApplicationHelper.handle(ApplicationHelper.java:72) at org.restlet.Application.handle(Application.java:400) at org.restlet.routing.Filter.doHandle(Filter.java:156) at org.restlet.routing.Filter.handle(Filter.java:201) at org.restlet.routing.Router.doHandle(Router.java:320) at org.restlet.routing.Router.handle(Router.java:519) at org.restlet.routing.Filter.doHandle(Filter.java:156) at org.restlet.routing.Filter.handle(Filter.java:201) at org.restlet.routing.Router.doHandle(Router.java:320) at org.restlet.routing.Router.handle(Router.java:519) at org.restlet.routing.Filter.doHandle(Filter.java:156) at org.restlet.routing.Filter.handle(Filter.java:201) at org.restlet.engine.ChainHelper.handle(ChainHelper.java:111) at org.restlet.Component.handle(Component.java:401) at org.restlet.Server.handle(Server.java:348) at org.restlet.engine.ServerHelper.handle(ServerHelper.java:71) at org.restlet.engine.http.HttpServerHelper.handle(HttpServerHelper.java:149) at org.restlet.ext.servlet.ServerServlet.service(ServerServlet.java:967) at javax.servlet.http.HttpServlet.service(HttpServlet.java:717) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at
RE: A simple URI problem
duh. thank you. webpost wrote: url-pattern/myResource/*/url-pattern router.attach(/myResource/buildings, BuildingsResource.class); That looks to me that you URL to buildings is http://localhost/ myResource/myResource/buildings. With myResource part duplicated. /Filip -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2377470 -- View this message in context: http://n2.nabble.com/A-simple-URI-problem-tp3363341p3377346.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2379511
Re: A simple URI problem -- followup
It is likely that my problem has to do with how I am defining my application in Tomcat. I'm not using a war file and in my server.xml file, i specify the default context Context path= docBase=myApplication debug=5 So, there is probably something that Tomcat is doing with a typical uri reference like http://127.0.0.1:9006/myResource/buildings/indiana btw, if i specify the typical mapping (url-pattern/*/url-pattern), then i get a nice xml rep of the indiana data -- but the rest of my application is broken since other servlets cannot be referenced. TKM wrote: I've spent several hours reading this nabble and online documentation and still can't get a simple variation of firstResources for Restlet 2.0 to work. In my case, i have a web app running on Tomcat 6.0.14 that i want to retrofit to include restlets. I have several servlets defined, so using /* as my servlet-mapping isn't possible. Everyone says you can specify a mapping that the Restlet API will recognize, but mine fails with a The server has not found anything matching the request URI message. I specified the URI via restlet.xml and as shown below. Access to the other servlets in the application are not affected, i.e. they work. my mapping in web.xml: servlet-mapping servlet-nameRestletServlet/servlet-name url-pattern/myResource/*/url-pattern /servlet-mapping the body of my applications createRoot() includes: router.attach(/myResource/buildings, BuildingsResource.class); router.attach(/myResource/buildings/{buildingName}, BuildingResource.class); // myLog.info(myResources:+router.get(/myResource/buildings).getEntityAsText()); // myLog.info(myResource:+router.get(/myResource/buildings/Indiana).getEntityAsText()); Output from catalina.log is good, so i know that the request is being passed to my restlet: Jul 31, 2009 10:09:25 AM org.restlet.engine.log.LogFilter afterHandle INFO: 2009-07-31 10:09:25127.0.0.1 - 127.0.0.1 9006GET /myResource/buildings - 404 330 - 1 http://127.0.0.1:9006 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.12) if i uncomment the getEntityAsText() calls in createRoot(), I get good results so I know my implementation of BuildingsResource and BuildingResource are working. does anyone see what i'm doing wrong? -- View this message in context: http://n2.nabble.com/A-simple-URI-problem-tp3363341p3364583.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2377528
A simple URI problem
I've spent several hours reading this nabble and online documentation and still can't get a simple variation of firstResources for Restlet 2.0 to work. In my case, i have a web app running on Tomcat 6.0.14 that i want to retrofit to include restlets. I have several servlets defined, so using /* as my servlet-mapping isn't possible. Everyone says you can specify a mapping that the Restlet API will recognize, but mine fails with a The server has not found anything matching the request URI message. I specified the URI via restlet.xml and as shown below. Access to the other servlets in the application are not affected, i.e. they work. my mapping in web.xml: servlet-mapping servlet-nameRestletServlet/servlet-name url-pattern/myResource/*/url-pattern /servlet-mapping the body of my applications createRoot() includes: router.attach(/myResource/buildings, BuildingsResource.class); router.attach(/myResource/buildings/{buildingName}, BuildingResource.class); // myLog.info(myResources:+router.get(/myResource/buildings).getEntityAsText()); // myLog.info(myResource:+router.get(/myResource/buildings/Indiana).getEntityAsText()); Output from catalina.log is good, so i know that the request is being passed to my restlet: Jul 31, 2009 10:09:25 AM org.restlet.engine.log.LogFilter afterHandle INFO: 2009-07-3110:09:25127.0.0.1 - 127.0.0.1 9006GET /myResource/buildings - 404 330 - 1 http://127.0.0.1:9006 Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.0.12) if i uncomment the getEntityAsText() calls in createRoot(), I get good results so I know my implementation of BuildingsResource and BuildingResource are working. does anyone see what i'm doing wrong? -- View this message in context: http://n2.nabble.com/A-simple-URI-problem-tp3363341p3363341.html Sent from the Restlet Discuss mailing list archive at Nabble.com. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2377446