Grails: get all files from War - grails

I am using Grails 3.1.1
Last month, I had my project, but my hard-disk became corrupted because of a bad sector. I tried bringing my hard-disk to a "Recovery DATA"'s store.
But that store cannot recover my data, so my project's data is gone now.
But I still have the War file on my customer's server.
I just want to know: Is it possible to get my project back from a War file?
My War file is still running on the server, but all my source code is gone.

No it's not possible to recover your entire project, including source code, from a WAR file. The WAR contains the compiled version of your code, not the source.

If you don't have any option and need to rewrite the application again, I'll suggest some ways:
Remove your hard-disk from laptop/desktop. purchase HDD internal sata to external USB case for desktop/laptop hard disk. which connects with connectors with circuit(Sometimes this helps you in boot-sector error also).
Connect it to the laptop and check is it showing HDD. If yes check data is available not. If HDD size showing correctly but data not available then you can recover data with " EaseUS Data Recovery" software.
If all above fails?
Copy your project war from server to local computer.
Install WinRAR or any other unzip software.
Select and open your war file with it.
See above screenshot,
Where assets folder contains js, css, images and all your other files.
which may be minified if you set minifyJs = true and minifyCss = true in your application.yml
Now, see very important folder called WEB-INF
See above image which contains two folders:
classes : This is very important folder which contains your controllers class files and gsp files.
Controller files are .class files where for each action from controller will generate separate .class file. You can de-compile dot class files using many online/offline tools.
In case of gsp you will get original files.
Also you will get application.yml and other files as it is.
Hope it helps you.

Related

Use settings file in .net core 3.1, single file published windows service

How to correctly use JSON settings files in windows services build in 3.1 net core, that are published in a single file.
Publishing as single file, requires you to do two things. First, exclude the settings JSON file from the single file. If you do not do it, it will be unpacked together with the rest, loaded and it will appear to work, if there are default values in it. And second, copy the settings file to the publish directory. You can do this by adding this:
<ItemGroup>
<Content Update="appsettings.json">
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</Content>
</ItemGroup>
In your pubxml profile. Building it from the interface with: Build > Publish (Project name) will not work. You gotta use the command line from now on.
Once packed into a single file, the base path of your application is changed. Simply placing the JSON files next to your exe will not do the trick. Also, you will be using windows services. Starting the exe is one thing, starting the service is another universe. In most situations you can use the following:
Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
To get the directory of your single-file packed exe service.
The packed exe checks the temp folder it creates for resources, you need to redirect some of the features to another folder. You will want to do this, at least for your log files and settings. For example, if you want the application to check for JSON files near your exe, you add this:
.ConfigureAppConfiguration((context, config) =>
{
config.SetBasePath(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName));
})
in your CreateHostBuilder method.
I hope that this will save you some time. Ive been fighting this all morning.

How do I put content into the iOS Documents folder at compile time, using Xamarin?

I have a data file that I need to include with my app when I distribute it. When loading any files in the app, I prefix the file name with:
Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
This works great for anything I create within the app (and for reading back), like files I download in response to a user action. But I can't for the life of me figure out how to place files there when I build my app in Visual Studio.
I've tried making a "Documents" subdirectory in the special "Resources" folder, but that didn't work (I tried setting the "Build Action" to both BundleResource and Content). When I look at the folder for my app (from using the simulator) I can see that in the "Documents" folder there's all the files I downloaded, but I can't find my data file that I'm trying to bundle ahead of time. I even searched my entire hard drive on the Mac and still couldn't find said data file.
The data file isn't an image, if it matters. Just raw binary data. How do I set it up so that this file goes into the proper documents directory at compile time, so that I can read it using the SpecialFolder.MyDocuments prefix? Thanks.
You can't. You can include files in your app bundle, and then at startup copy them from the bundle into a user folder. But this won't happen automatically.

how to convert java webapplication into single exe file?

I want to convert my struts2 web application into an exe format so that exe file will load my project into server and database into MySQL.
Are there any such tools available for loading files into a folder?
Are there any forms other than .exe to which I could convert my project to do this action?
Is it possible to decrypt the code from class file to java file?
Which is the most secure form for a struts2 project for loading into a server?
You want to convert it to executable one?? generally installer came to assist auto installation like if you have created a product using all these technology and you want save your customer from all the setting and installation processes like database configuration,other configurations etc.
Is it possible to decrypt the code from class format to java format
there are many java d-compilers available which help you to convert .class files to java files though they sometime fails to convert it 100% but in most cases they tend to show some one what they actually want to see.
You can't load an exe file into a web server.
I suppose you could create an executable that includes a server and your war file, but I would strongly discourage the practice.
You could obfuscate (e.g., with ProGuard) and/or encrypt your .class files, but if they're determined to get to your unobfuscated byte code, they almost certainly will.
If they're not that determined, then it's probably not important enough to go through all the effort, debugging, and so on.

Bug in MonoTouch/MonoDevelop or something else?

I load up a few XML files with my app in Mono when deploying to iPhone. I edited one of those XML files in Windows through a LAN connection to the Mac on which the file resided. After editing the xml file the app seems to refuse the xml file exists anymore. THe properties are still 'copy always' and 'content' where relevant for the XML file, I know it exists and I can even open and edit it MonoDevelop. But in app isolatedstorage.fileexists("filename.xmL") ALWAYS returns false.
I deleted the file and daded it back in, I copy+pasted the file, heck, I even renamed another xml file to the same filename and that xml file stopped being recognized.
Not sure what to do now?
Did you try "File.Exists" ?
Keep in mind that IsolatedStorage's main goal is to isolate the files from outside (the application) usages. As such MonoDevelop will copy to the application folder, but not in the isolated storage. Same is true for desktop applications, MonoMac apps...
FWIW IsolatedStorage API exists in MonoTouch to help you port existing code (from the 'desktop' framework or WP7) but there's no reason (beside portability) to use it. In iOS applications are already isolated (from each other) and so are their files.

Finding unused images in a Rails app?

I'm familiar with tools like Deadweight for finding CSS not in use in your Rails app, but does anything exist for images? I'm sitting in a project with a massive directory of assets from working with a variety of designers and I'm trying to trim the fat in this project. It's especially a pain when moving assets to our CDN.
Any thoughts?
It depends greatly on the code using the images. It's always possible that a filename is computed (by concatenating two values or string substitution etc) so a simply grepping by filename isn't necessarily enough.
You could try running wget (probably already installed if you've got a linux machine, otherwise http://users.ugent.be/~bpuype/wget/ ) to mirror your whole site. Do this on the same machine or network if you can, it'll crawl your whole site and grab all the images
# mirror mysite.com accepting only jpg, png and gif files
wget -A jpg,png,gif --mirror www.mysite.com
Once you've done that, you're going to have a second copy of your site's hierarchy containing any images that are actively linked to by any page reachable by crawling your site. You can then backup your source image directory, and replace it with wget's copy. Next, monitor your log files for 404's pertaining to gif/jpg/png files. Hope that helps.
Finding unsed images should be easier than CSS.
Just find *.jpg *.png *gif with glob, put those filenames to dictionary or array and find those filenames againt html, css, js files, remove filename if found and you will get unused list, and move those images to another folder with same directory structure (It will be good for restoring for just in case)
Basically like this, and of course for the file names that encrypted/encoded/obcuscated will not work.
require "fileutils"
img=Dir.glob("**/*.jpg")+Dir.glob("**/*.png")+Dir.glob("**/*.gif")
data=Dir.glob("**/*.htm*")+Dir.glob("**/*.css")+Dir.glob("**/*.js")
puts img.length.to_s+" images found & "+data.length.to_s+" files found to search against"
content=""
data.each do |f|
content+=File.open(f, 'r').read
end
img.each do |m|
if not content=~ Regexp.new("\\b"+File.basename(m)+"\\b")
FileUtils.mkdir_p "../unused/"+File.dirname(m)
FileUtils.mv m,"../unused/"+m
puts "Image "+m+" moved to ../unused/"+File.dirname(m)+" folder"
end
end
PS: I used fileutils, because normal makedirs and mv are not works in my windows version of ruby
And I am not good at ruby, so please double check it before you use it.
Here is the sample results I ran in root folder of sample rails folder in my windows
---\ruby>ruby img_coverage.rb
5 images found & 12 files found to search against
Image depot/public/images/test.jpg moved to ../unused/depot/public/images folder
If your image URLs often come from many computed / concatenated strings and other stuff hard to track programmatically within your source code, and your application is in heavy use, you could try a soft "honeypot" approach like this:
Move all the assets to a different directory, e.g. /attic
Set up an empty /images directory (or what your asset directory is called)
Set up a .htaccess file (if you're on Apache of course) that, using the -f flag, redirects all requests to nonexistent image files to a script
The script copies the requested file from the /attic into the /images directory and displays it
The next request to that image will go directly to the image, because it exists now
After some time and sufficient usage, all needed images should have been copied to the assets directory.
It's a "soft" approach of course because a dialog / situation could have not been opened/entered/used by any user during that time (things like error message icons for example). But it will recognize all used files, no matter where they're requested from, and might help sort out much of the unneeded files.
If your file manager supports it, try sorting your images directory by the files' "last accessed" date. Files that haven't been accessed in a long time most likely aren't used any longer.
Along the same lines, you can also filter or grep through your web server's logs and make a list of the image files that it has served up in the last several months. Any images not in this list are likely unused.

Resources