It's all about the answers!

Ask a question

How to write to a file on the Workspace (server-side) ?

Ehud Hoggeg (1324) | asked Feb 24 '14, 5:31 a.m.

We wish to update (or create) a text (xml) file on the workspace, on the server-side, upon "save" operation.

We managed to do this on the client-side sandbox and got the "unresolved" file as expected.
Our goal now is to move this functionality to the server and write the file on the user's workspace.

Given an IFileItem ift, we need to change it's content (we don't have the exact path to it, since there's no "sandbox" as was on client-side case), while creating a new version of this file (i.e. new State) and then check it into a newly created change-set.

Can anyone please provide an example that does similar thing?
If not, maybe someone can explain the needed steps to achieve that or recommend on the right practices to do this?


Ralph Schoon commented Feb 24 '14, 6:04 a.m.

I am not sure if that is possible. I would be very concerned with adding a file to the repository workspace of a user, if that is loaded on disk. If the file is added to the workspace without being available on disk, I would assume you will have created a situation where the local and the repository workspace is out of sync. You would have to add the file to the stream to make it available for accepting into the users workspace.

I have posted some client code here: you might be able to use some of the capabilities, but it is client code.

Ehud Hoggeg commented Feb 24 '14, 6:56 a.m.

Thanks Ralph. I understand your concern.

We may "relax" the need to create such file and assume the file exists and is available on the disk just as well (when the user copied the stream, he got that file along with it).
How ever, the request is to manage this file in an automatic manner, on the server side. This is a fundamental requirement of our case.

This is not exactly what we do, but I think you may imagine a log file, that logs every time a "save" occurs.
User should not bother himself with the writing such file's content - it should occur automatically, but he may want to "read" it for review.

As I explained, we managed to do this on the client side properly.
We need to move this functionality to the server side.

Tim Mok commented Feb 24 '14, 9:26 a.m.

If this is a log of operations on the repository workspace, it seems odd to save this log to the repository workspace. I think your requirement for logging makes sense but it might not be necessary to check-in the file. It would be better if this information was stored in another way.

Geoffrey Clemm commented Feb 24 '14, 12:18 p.m.

Rather than writing the change to a workspace, I suggest writing the update to a stream.  That avoids the problem of disrupting a workspace's relationship with a sandbox.

Be the first one to answer this question!

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.