Posts

Showing posts from January, 2019

Compatibility between JDK and AWS

Have been spending 2 week to figure out the bug "Could not initialize class com.amazonaws.http.AmazonHttpClient" Considering all the matching source code, I suppose JDK is the highly probable cause for this error. Will check tmr. Annoying... https://github.com/aws/aws-sdk-java/issues/1757 https://web.liferay.com/services/support/compatibility-matrix

Interface

Does anyone here know how a soda machine works? (Cue confused glances about why we'd even talk about this.) No? Let me tell you. You drop in your change, and inside the machine is a little monkey who counts all your change to make sure you put in enough money. When you press the button for your soda, a little light comes on telling the monkey which button you pressed, and if you entered the right amount of change, he grabs your choice and throws it into the little hole for you to grab your soda. This is the concept of encapsulation. We hide the implementation of the soda machine. Unless it's got one of those fancy, clear windows to let you see the inside, you honestly have no idea how it really works. All you know is that you put in some cash, you press a button, and if you put in enough, you get your drink. To add to that, you know how to use a soda machine's  interface , so therefore as long as the machine's  interface  follows the usual soda machine interface,

Adding portlet to control panel

Getting the crrent portlet Id can be done through themeDisplay. ThemeDisplay themeDisplay = (ThemeDisplay) renderRequest .getAttribute(WebKeys.THEME_DISPLAY); If you want to retrieve portlet Id in View, this is the typical way to do it. However, when you are in Portlet class (java), you can directly get it through request using some Util class (ex PortletUtil... not this one tho) I could not find the appropriate util, so I am gonna just apply the themeDisplay way. found it PortalUtil.getPortletId(HttpServletRequest request)
Prevent users with unverified email address from logging in (not able to sign in with unverified email ) 1. modify the return value of loadUserByUsername() in UserServiceImpl 2. Create a new user and try to sign in without Email verification step Add code to send email 1. Create AmazonSES under shared package -check contact path in properties file for verification link 2. add code to CreateUser in UserServiceimpl 3. test Creating user (with the verified email if you have not moved out of aws sandbox.) internet needed. 4. check email Reset Password 1. requestReset in User controller 2. create  PasswordResetRequestModel in Request package 3. add resetPassword to RequestOperationName 4. implement resetPassword logic in service layer 5. implement generatePasswordResetToken in Utils Creaet PasswordResetTokenEntity & Password Reset Repo 1.

elaelaela

Image

How to use expando attribute for tracking user activation

Image

Top Java App Server - Servlet Container

https://stackify.com/tomcat-vs-jetty-vs-glassfish-vs-wildfly/ Tomcat Server is a servlet container What is a Servlet? A Servlet is a java object from a class which extends from javax.servlet.http.HttpServlet. This is not exactly true because there is different types of Servlets but HttpServlet is clearly the most used. What is a Servlet Container? A Servlet Container is a program which can receive requests from web pages and redirect those requests to a Servlet object. How does this Servlet Container work? The Browser asks the HTTP server for a page, which is a Servlet Container. The Servlet Container delegates the request to a particular Servlet chosen between the Servlets it contains. The Servlet, which is a java object, is in charge of generating the text of the web page delivered to the container. The container returns the web page to the Browser which made the request.

Postman Sample calls

1. Create - POST localhost:8080/my-restful-web-app/users Content-Type : application/json { "firstName" : "Claire", "lastName" : "Min", "email" : "clairemin@gmail.com", "password" : "1234" } 2. Login - POST localhost:8080/my-restful-web-app/users/login Content-Type : application/json { "email" : "clairemin@gmail.com", "password" : "1234" } 3. Email Verification - GET http://localhost:8080/my-restful-web-app/users/email-verification?token=eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJISE1oR2tVbVJKTU5JV3F5dW00U3JPSTFCMlB4V2UiLCJleHAiOjE1NDc1MDE4NzN9.A066qEj8RCnU6GUsBXwMZup3gloVYClZ4c0qOo64a9gHpMzhJ05m7-G-t1sSVPKIgwFuY90y5p6KJ4D5W7C76g Authentication : Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJkYXZpZEBnbWFpbC5jb20iLCJleHAiOjE1NDc1MDE5NDN9.xeI7wmd89ey-MaEuZg6s6a4p6LMQLPtGzW9FSJd94QrOngL90iiUwe7PN4ZfiJx2FuQnC9tcUcSdFrSLEPSG1A

What is WAMP Server

https://www.wpbeginner.com/glossary/wamp/

Liferay Search Migration from 6.2 to 7.1

In Liferay 6.2, search scope used to be specified by groupId (site) , whereas 7.1 defines the scope either only as Everything or This-site by enum value. The way to specify search scope itself has been simplified (minimized?), but still search result can be filtered by Search facets which accepting groupId, assetEntryId, etc as search criteria. No need for modification in API yo Done! https://github.com/liferay/liferay-portal/tree/7.1.x/modules/apps/portal-search/portal-search-web https://github.com/liferay/liferay-portal/tree/6.2.x/portal-web/docroot/html/portlet/search

How to make Restful web service api support user email notification feature

Image
* How to implement user email notification feature * use Amazon Simple Email Service(SES) to send email messages to users programatically * create email notification links that expire in certain amount of days or hours * confirm user email address Spring Security, Make email verification a PUBLIC web service endpoint - not require authorization header (HTTP GET request whose URL contains verification token as query string) 1.go to WebSecurity.java, and modify configure by adding antMatchers  for Verification Email RUL 2.add constant to SecurityConstants.java Receive HTTP GET reqeust and read email verification token from url 1, verifyEmailToken() in RestController. Add verifyEmailToken() Service to Service Layer Function Add findUserByEmailVerificationToken() to Data Layer function Add hasTokenExpired() to Utils class Generate and Save the emai verification token in our DB 1. add the followings to createUser in userServiceImpl userEntity.setEmailVerification

How to install Maven on Windows

1. Download and install Apache Maven 2. Set up environment variable on system. https://youtu.be/Jtj-0yhox5s