We are using Java + RESTfull (jersy) webservices and return objects (xml file in svn repo) by opening a stream to an url directly.
However now I need to return a specific revision object (specific revision xml file from svn reporsitory). I am able to use svn api's and checkout that file on to the server locally. Unfortunatly I have no idea how to stream this to an url directly and transport back to client.
Could anyone guide me on this ?
To support requesting arbitrary revisions mod_dav_svn supports a query argument. For examples to request revision 1430000 of the CHANGES file on Subversion's trunk you'd use:
https://svn.apache.org/repos/asf/subversion/trunk/CHANGES?p=1430000
The p stands for peg revision. So you can even specify paths that have been deleted. For instance this URL works:
https://dist.apache.org/repos/dist/dev/subversion/subversion-1.7.14.tar.gz.asc?p=3664
Even though trying the same URL without the peg revision argument doesn't work because the path has been deleted in the HEAD revision:
https://dist.apache.org/repos/dist/dev/subversion/subversion-1.7.14.tar.gz.asc
Related
We are integrating Office Online with our application to open Open Microsoft Office files(.docx, .xls, .pptx, etc.). To do that, we use the WOPI protocol.
These files can be local files or files hosted on SharePoint.
For SharePoint files to open them with office online through our application, we have to perform the following steps:
the control comes to WOPI getFileInformationCall
we need to hit the Microsoft graph API
to download the file
we read the file and return the file information from the REST call.
This all steps take time and are a bit fragile. Does anyone know if there is a way to redirect WOPI REST calls to get SharePoint files? Or is there another way to optimize these steps?
You can return FileUrl as a property returned from CheckFileInfo operation.
FileUrl is a URI to the file location that the WOPI client uses to get the file. If this is provided, the WOPI client may use this URI to get the file instead of a GetFile request.
has any one tried to purge content using Open Api Purge V3 using java. As i am not able to understand the process by their documents provided on Akamai portal.I referred this below link to proceed but no luck till now
https://community.akamai.com/customers/s/article/OPEN-API-Fast-Purge-and-Java?language=en_US
Also another question, is their any possibility to purge by directory instead of purge by URL in Fast Purge API via java code using open API.
We cannot purge by directory using APIs. You will have use something called as ECCU to purge directories. I would assign a CPCODE for the directory of interest to be purged and then use CPCODE to purge.
Regarding Java code, i would suggest you to copy and paste the code into a file and trace it. Ideally following are the steps.
Read the credentials (usually from .edgerc file)
Establish a session to Akamai API server
Build the POST object containing URLs and CPCODE.
Issue a POST request, and expect a 201 response.
I am searching for a way to archive files in a revision-save way.
I imagine a java based rest service, to pass a file, which is then unchangeable stored and accessible via an URI.
How could I implement something like this? Is a Hadoop Archive a possible building block? Or is this only possible using a Content-Addressed Storage?
I think the best solution is to compute a checksum for each file and return the ID of the file together with the checksum as a combined access URL. Than each time a client requests a file via the URL (including the checksum), the service verifies the checksum again and can so garantie, that the file returned was not modified from the point of time when the file was stored and is identical to the version the client expect. The URL is the surety of the immutability of the requested file.
Also the client can verify the checksum if the client did not trust the service.
Can I configure, create/update the existing project in Hudson without using its user interface?
Is it possible by changing configuration file or other mean?
The Remote Access API page mentions that you an create/copy job with it.
Remote access API is offered in a REST-like style.
That is, there is no single entry point for all features, and instead they are available under the ".../api/" URL where "..." portion is the data that it acts on.
For example, if your Hudson installation sits at http://deadlock.netbeans.org/hudson/, http://deadlock.netbeans.org/hudson/api/ will give you HTML lists of all available functionality that act on the Hudson root.
On my Hudson, the /api address gives:
Create Job
To create a new job, post config.xml to this URL with query parameter name=JOBNAME.
You'll get 200 status code if the creation is successful, or 4xx/5xx code if it fails.
config.xml is the format Hudson uses to store the project in the file system, so you can see examples of them in /server/path/to/your/hudson/home.
I have the directory mapped on my machine so that I can browse and write to it via Windows explorer. I would like to write files via java.
File f = new File("http://dev1:8080/data/xml/myTestFile123.xml");
f.createNewFile();
I am getting the following error:
Exception in thread "main" java.io.IOException: The filename, directory name, or volume label syntax is incorrect
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(Unknown Source)
at MainTest.createTestFile(MainTest.java:156)
at MainTest.main(MainTest.java:72)
Is there any way to write files to a mapped directory that has the http:// in front? Because thats the way the directory is provided to me. It is a virtual directory that an oracle database is creating.
My understanding is that you are trying to write to an Oracle XML DB Repository. Oracle XML DB Repository is a feature that has been introduced by Oracle9i Database Release 2 for XML storage and that can be accessed through FTP or HTTP/WebDAV. In your case, it looks like you're trying to use HTTP/WebDAV.
As explained in the WedDAV page on Wikipedia:
WedDAV is a set of extensions on
top of HTTP that allows users to edit
and manage files collaboratively on
remote World Wide Web servers.
In other words, adding files, deleting them, renaming them, etc in a WebDAV repository is done using HTTP words: PUT, DELETE, MOVE, etc (see RFC 4918 for more details).
Consequently, interacting with a WebDAV server can be done using classes from java.net.
Or you could use a higher level API like Jakarta Commons HttpClient.
Or you could use a Java WebDAV client like the one provided by the Slide project. This article shows how to do it and it looks simple. However, as the Slide project is now retired, I wouldn't recommend it.
Luckily (or not), the Apache Jackrabbit project is an alternative to Slide... but AFAIK the WebDAV support in Jackrabbit is more focused on server-side implementations than clients. Anyway, you'll find some code samples in this thread on the jackrabbit-users mailing list.
I think I'd choose HttpClient and use the Tutorial or the Sample Code as starting points.
I'm not really sure what I'm talking about here (not a Java guy) but although you may "have it mapped" you're passing in a URL instead of an expected file system path. If (for example) you have a mapped drive under Windows, use the drive letter assigned.
Your trying to pass the location URI with a protocol. You need to pass location sans protocol:
\\dev1\data\xml\myTestFile123.xml
Instead of trying to using a mapped drive letter (seems very weak), have a look at JCIFS:
JCIFS is an Open Source client library that implements the CIFS/SMB networking protocol in 100% Java. CIFS is the standard file sharing protocol on the Microsoft Windows platform (e.g. Map Network Drive ...). This client is used extensively in production on large Intranets.
This piece of code shows how to Logon to a Remote Machine and Write File using jCifs (credits to Muneeb Ahmad):
import jcifs.smb.NtlmPasswordAuthentication;
import jcifs.smb.SmbFile;
import jcifs.smb.SmbFileOutputStream;
public class Logon {
public static void main( String argv[] ) throws Exception {
String user = "user:password";
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication(user);
String path = "smb://my_machine_name/D/MyDev/test.txt";
SmbFile sFile = new SmbFile(path, auth);
SmbFileOutputStream sfos = new SmbFileOutputStream(sFile);
sfos.write("Muneeb Ahmad".getBytes());
System.out.println("Done");
}
}
Edit: As mentioned in a comment added to the original question, my understanding is now that you are trying to write to a WebDAV directory. I'll cover the WebDAV topic in another answer for more clarity.
How have you mapped the file in Windows? I suspect it is not using the HTTP protocol, because no such mechanism exists for creating files. So you will not get anywhere using "http" as your protocol.
Find the mapped drive letter, you probably want something more like:
File f = new File("F:\\dir\\file.ext");
If you are using Samba you might want to take a look at JCIFS then you can use:
smb://server/share/
Use the local path
If you can see myTestFile123.xml in windows explorer, then right-click it and copy the Location: property value. Then use exactly this as the new File() argument, but either double up the backslashes or change them to forward slashes.