Getting the File Signature of a File through Lotus Script - java

Is there a way to get the file signature of a file inside a document? I tried checking the Embedded Object Class but it seems that there is no function for getting the file signature. Is there a way to get it just by using lotus script?
If not then I believe I'll need to maybe use a java class agent right? Can you provide a link that is doing this function or maybe can you guide me with some codes for this one. I am familiar with java but when it is being used in lotus notes agents I am not much familiar with the class being used.
Basically what I need to do is check the files in the documents and check if they are a valid file with the valid signature. Just checking the extension name is not enough as it might be renamed but the signature of the file is not valid so I'll need to confirm the file signature in checking. Thanks.

You have to write the file to file system and then you can read the file from there. Use a temp directory and delete every file after usage.
Look here for code to write attachments to file system as a starting point. Property EmbeddedObjects is available for documents too in case you want to analyse all attachments of a document.
You can accomplish the same in Java. Just look for Java classes in Language cross-reference in documentation.

Related

How to use file associations with jpackage?

I am using jpackage to pack my Java application and want to use it to create file associations. I see that the utility supports this via the --file-associations command. Using this, you can point it to a file that includes file association information.
Does anyone know of documentation that gives a better description of how to create this file-association file? The help documentation in the utility itself describes keys that must appear in it, but there's no hint at how it needs to be formatted.
Here is what the packager lists in its own help:
--file-associations — Path to a Properties file that contains list of key, value pairs (absolute path or relative to the current directory). The keys "extension", "mime-type", "icon", and "description" can be used to describe the association. This option can be used multiple times.
Does anyone here know where I might be able to find an example of this that is written correctly or more detailed documentation on exactly how the feature is used? Would be much appreciated if someone could just point me in the right direction.
You need to write each key-value on each line separated by an equal sign without any quote and save as a text file with .properties extension for example
extension=<Your file extension without leading dot e.g. docx>
mime-type=<Your mimetype e.g. application/msword>
icon=<Path to the icon file e.g. word.ico (Windows) or word.icns (macOS)>
description=<Some description e.g. Microsoft Word Open XML Format Document>
I could not find any official documents either. However, this is how I created my properties file which works on the release version of Java 14.

Creating a file just to be uploaded into the online form

couldn't find relevant question on SO I'm asking a new one. I can create a file using FileWriter class, but it requires to specify the path for that file (physically creates the file). What I want to achieve is to create a file like in-memory, without specyfying the path or saving it on the disk and then upload it into the online form with selenium webdriver, is that somehow possible?
But there also is another problem, html fileUpload element will accept the path such as:
driver.findElement(By.id("Content_CV")).sendKeys("C:\\Users\\name\\Documents\\my_cv.pdf");
but will it accept the file itself? Probably not, so assuming that some of you knows how to create a file without saving it on the disk, would there be a way of providing path to that file anyway (given its virtual location)?
I'm trying to figure it out and I did some google research, yet here I am. Thanks for any attempt of help :)
If your question is just how to create a temporary file without caring about how to name it and where to create it without overwriting existing files, then you can simply use File.createTempFile. This will create an actual new temporary file on disk in the directory designated by the operating system for that purpose. You might also want to have a look at File.deleteOnExit.
If you are not looking for a java solution, you can simply create the file in a RAM drive
Software for this exist for all mayor operating systems.
Have a look at the wikipedia link above for more information.

how to shift from swiprolog to tuprolog

I got a .pl file through an eclipse plugin called JTransformer.The problem is that the .pl file I got is based on swiprolog and now I need to do query based on prolog in a java file which is easy to achieving using tuprolog. But I can't consult the .pl using tuprolog, since it was writen in swiprolog and there were some marks that only supported by swiprolog. What can I do to change it from swiprolog to tuprolog. The .pl file is in my google drive https://drive.google.com/folderview?id=0B4KCEwRVmr_yWjQwOEp3LWpYdk0&usp=sharing .
At first glance, that file has very little specific to SWI. You could try to remove altogether any directive: those lines beginning with :-. Then build you theory - I think that's tuProlog way to modules and see if you're ready to go.
Those directives, for instance :- dynamic factbase_export_time_stamp/2., eventually should be changed to :- dynamic(factbase_export_time_stamp/2)., instead of being deleted, depending on your use case. The same holds for :- multifile ones.

How to find file extension if the file has been renamed?

How to find file extension if the file has been renamed? Is there any tool are available for this?
Example: I have a file "1.doc"; I hope everybody know this is a Word document I just renamed as "1.txt". But the file is a Word document originally; how can I get the original file extension?
You cannot get the previous file extension back. All you can do is look at the contents of the file, and try to guess what it is.
Most (many?) file formats begin with a "magic" value that is intended to identify the file format, but this method can never be 100% accurate.
As #AaronDigulla mentionned in a comment, there are libraries out there that help you in the task of "guessing", and the answer(s) to that question contain pointers to some such libraries.
Once you rename the file, the previous name is not preserved.
As far as automatically guessing the format of the file from its contents, take a look at the Unix file utility. The version that's installed on my Ubuntu box lists Microsoft Word among the "magic" signatures that it knows about.
What you want to do is find out what its MIME type is. You can use this tutorial http://www.roseindia.net/java/java-get-example/get-mime-type.shtml
before renaming it save it in a separate string called originalName...because when you change the name of the string, the memory allocated is changed and theres is no go back or undo
Consider using javax.activation.FileDataSource from the JavaBeans Activation Framework. In particular use the getContentType() method.

How to find the version of a File on windows through Java program?

I want to design a function in Java which will have prototype like this.
public String FindVersion(String FullPath)
{
}
where FullPath can be: C:\tmp\readme.txt
or C:\windows\system32\xcopy.exe
or like C:\windows\system3
FileVersionInfo is a Win32 API thing so you'll need to use the JNI and some C code to get access to it or use an external library. There is a an API I found called Sigar that seems to be able to do this
The details that you are asking are very specific to the file-system of the operating system on which the Java runs. As of until Java 7(java.nio.file.attribute); we don't have any API that gives you this information. The only option is to make use of some Win 32 API through the JNI interface.
Not all files track versioning, the average text file has no concept stored within the file or externally which encodes how many times it has been edited.
Some documents optionally store versioning information within the document, if enabled. For those files, the routine would look something like (in pseudocode)
public String FindVersion(String filepath) {
check to see if file type can be deduced;
check to see if the deduced file type supports versioning;
check to see if the file has versioning information;
go through the revisions of the file and report the latest one;
}
Some documents are versioned, but the versioning information is not stored within the document, it is stored in a system which tracks the versioning information independently of the document. In such a case, you really want to deal with the revision control system which is authoratative over the document. Often such system have utilities to indicate which version of the controlled document was last retreived; other times you need to query the document against all revisions looking for the closest match.
Basically, there's not one way to do it for every situation.

Categories

Resources