Skip to content

Publish/Unpublish Adobe AEM page from Java

We have background process that automatically creates AEM pages as well as deletes old AEM pages. For pages to appear/disappear on the published site, they need to be activated (Published) / deactivated (Unpublished). However, after searching from Google, I am not able to find AEM Java API that can publish/un…

Spring JPA no transaction is in progress

I am new to Spring and JPA, wasted 5 days and no result with searching internet. I want to save object to SQL SERVER, connection is correct but when I write .flush() I get the exception nested exception is javax.persistence.TransactionRequiredException: no transaction is in progress This is my jpaContext.xml …

How to Count Number of Instances of a Class

Can anyone tell me how to count the number of instances of a class? Here’s my code The class variable is to be used to keep count of the number of instances of the Bicycle class created and the tester class creates a number of instances of the Bicycle class and demonstrates the workings of the Bicycle c…

Encrypt password fields in mongodb

I have following code, it insert the userName and password into database but the password is stored in plain text format. I mean when I’ll look into the db I can see the inserted password. I want to store password in encrypted format How can I achieve this? Answer According to the conversation in the co…

How to check does interface with generic fit to class

I have some interface with generic type interface DummyInterface<T> and i have class to which i have to set interface Imagine the situation where i store DummyClass with different generics in ArrayList. When i get class from list i don’t know the generic of class, and i want to check if interface …

java Cannot delete file, being used by another process

I have this code and when I execute it it says java.nio.file.FileSystemException The process cannot access the file because it is being used by another process (in sun.nio.fs.WindowsException) In the sameSha1() I have this: I want to delete the file ‘SHA1.txt’. How can I do this? Answer I guess wi…

How do I disable Java assertions for a junit test in the code

How do I disable java assertions (not junit assert) for a junit test in the code Ive written a junit test but when I run it it doesnt fail as expected because assertions are enabled, whereas they are not in production. Is there a way to disable assertions just in the code so that it work as expected when run