I need to programmatically set the date the OS returns to Java - date

I need to set the date that JVM would normally get from the OS.
Why? We have an app that interacts with a legacy app. All data on the legacy is always some date in the past (the client does reporting on a saved copy of live data (yesterday's data ) so as not to affect the response time of transactions on the live machine and demo's are done on dev machines, also some date in the past)
Our app needs to post transactions no later than the date on the legacy app. The legacy app lives on a different server. We have a process that returns the current date of the data and need to get the Java app to work entirely on that date.
We can't change the system date since a datawarehouse also runs on that box. So the only alternative is to change the date that JVM thinks it's getting from the OS.
Any ideas?

Own java agent should do the trick:
http://blogs.captechconsulting.com/blog/david-tiller/not-so-secret-java-agents-part-1
I suppose that intercepting System.currentTimeMillis() calls should be enough.

Related

Amazon S3 getDate() API Call?

Is there a way (API call) to know the current time on an Amazon S3 server?
Here is a bit of background to explain why I need this:
I have an iphone app that sometimes has to download a set of files from a bucket on a Amazon AWS S3 account.
Between two such downloads, the server files may be modified by a CMS (Web Content Management System), or not.
So, when a second download occurs, The client app tries to be efficient by downloading only the files that have been modified on the server since the previous such download.
To achieve this, the app stores the date of the last download and when a new download occurs, it just focuses on the files that have been modified on the server since the date of the last download (using there “modified date” property accessible using the SDK listObjects() function).
The problem with this is that the date on the phone and the modified dates on the s3 server may not be compatible. The phone user may have changed his phone date & time settings, etc.
To make this work, the saved “last download date” should come from an Amazon S3 API call to make sure all dates used by the app logic are in sync.
Is there such thing? Or maybe an alternative or a workaround?
You could use a file hash instead of the modified date. An Amazon S3Object has an etag property that is indeed such kind of hash. You retrieve this property the same way as you access date.
Have your client device save this hash along with the file. The next time you connect to the server, ask for the etag using the method about and compare the returned value to your local copy.
A different etag value will indicate to the client that the file has changed since the last download. This approach would be completely independent of any datetime functionality.

File syncronization between iPhone and a server

Can anyone suggest the best framework, method, library I could use in iPhone (use in development, not a ready application) in order to achieve syncronization between a fileserver and a local storadge on iPhone ?
I am doing this for one of my apps and the way I've implemented it is using a Ruby & Sinatra webserver, talking to a MongoDB database. You could use any other database and webserver technology.
The basic concept is this:
Every time an object in the database is updated, the timestamp is recorded for that object.
A global, last updated timestamp is also updated.
The app contacts the webserver and asks for updates, passing along a locally stored "last updated" timestamp.
The webserver processes the request by first checking the global timestamp and making sure it is older than the app's timestamp. (This is to save having to scour the database if no changes were made to it. My model is: Big data that is not changed frequently. If you have data that changes frequently, then there is probably no benefit to this global timestamp.)
The webserver then finds every object in the database whose timestamp is newer than the app's timestamp.
The webserver packages this up inside a JSON object, and returns it to the app.
This is all RESTful in the sense that it is a stateless transaction, so the app's implementation is very simple (a simple NSURLRequest, followed by JSON decoding, followed by error handling). Now you have an array of updated objects and you can merge these with your local storage in the app.
Another nice point about this (stateless) approach is that you can run it on Heroku (for free).
From what I can tell, there is no easy way. I was looking for an rsync equivalent, but I haven't found one.
In my case, I'm manually walking the tree asking the server for differences after a certain date and I remember the last successful sync date.
Not pretty. Could spend lots of time coming up with something sophisticated.

Is it possible to get a users timezone for an application hosted by Citrix XenApp?

I have a VB6 application hosted to users around the world through Citrix XenApp. I'm using the windows GetTimeZoneInformation call to find the time zone of the user in order to adjust some dates shown in the app (the dates come to the app in GMT). Unfortunately it looks like GetTimeZoneInformation gets the timezone of the Citrix server rather than the user running the application. Is there a Citrix based solution for this or am I going to need to change my implementation? This seems like a pretty big hole for Citrix hosted apps as I imagine you'd have the same problem with other localization settings.
What you ask should happen automatically: that applications do not get the server's but the client's time zone when asking Windows for the time zone. Here is a good description of how this works (PortICA, by the way, was a kind of early code name for XenDesktop).
If it does not work: client time zone support can be disabled, or any number of other things may have gone wrong. Check Citrix KB article CTX303498 for possible solutions.

which xcode application for pre filling a database

I am still learning xcode and objective-c. I use to build app for iphone environment only.
However I am in need of realizing an application with an existing prefilled sql database.
For prefilling the database I wouldn't like to use code in the ditributed app, but I would rather prefer to have a separate app for doing that.
The reason is that, the app could only download the updated database, rather than a whole code update .
So, questions are:
is this a possible scenario
if yes, what kind of application
should I build in xcode for
prefilling database ?
thanks
There's no reason that you can't have one app that both uses the database and downloads updates. Keeping the database updated without downloading the whole thing is pretty simple.
If you record the creation and modification timestamps of rows in the database on the server and keep track of those same modification timestamps on the device, updating the database works like this:
The device determines latest modification timestamp it has for a given table. We'll call it latestTimestamp. It sends the latestTimestamp to the server.
The server compares the latestTimestamp to the creation and modification timestamps in the database. The server sends back data based on the comparison result:
If the modification timestamp is earlier than latestTimestamp it doesn't need to send the record, the device already has it;
If the modification timestamp is later than latestTimestamp and the creation timestamp is earlier than latestTimestamp, it sends the record back noting that it is to be updated in the device database;
If the modification timestamp is later than latestTimestamp and the creation timestamp is later than latestTimestamp, it sends the record back noting that it is to be added in the device database.
Lastly, the server database needs to keep track of deleted records and a deletion timestamp for every record recorded. If latestTimestamp is later than the deletion timestamp, it sends back that the record needs to be deleted.
Obviously it gets a bit more complicated when you have a variety of connected tables, but as long as things are sent back in the correct order, it works great.
Use asynchronous data requests (the ASIHTTPRequest library makes it a breeze) and update the data in the background while the user uses the app. If it's essential that the data be updated prior to any interaction with it you can display an activity indicator and have the user wait.
No need at all for a separate app.
I would discourage you from doing that. No matter it is a pre-filled-database-purpose app, or a normal-purpose app, Apple Review Team would treat them with the same procedure, leaving the developer waiting for weeks before that app is finally available on App Store.
Besides, as far as I know, communication between apps is still strictly limited. If the data you would like to transfer between your main app and your db app is larger than a few lines of, let's say, NSString, it might be technically un-plausible.

How to set a static system date for one user or application--"Groundhog Day"

I have a vendor application on AIX which requires the system date to be set to an arbitrary value for QA testing purposes. The application gets its date from the system, and there is no possibility of changing it to get the date from a parameter. The application runs under a specific userid. I'd like to find a way to set the date for this application or user to a private value without affecting all the other users and applications on the system. So far the only thing I have been able to do is dedicate an LPAR to this application. Every day at midnight a root crontab job resets the date to the static value. This works, but it is wasteful of resources; and now I am faced the requirement to do this for other applications, which, of course, require different dates. Is there any clever solution to this? I need a way to create a sandboxed environment where the date returned from the system can be set to a private value. As I said, the OS is AIX, and that can't be changed for this application either.
You might be able to build a mutant system library (whatever AIX uses for dll/so) that intercepts the date system call and passes everything else on to the real lib. I can think of several way that would fail and several more why it's not a good idea, but it could work.