Posts

Showing posts from November, 2018

How to include CSS, JS and Image in Liferay Portlet JSP

Image
In Init.jsp,  add the following plug-ins to enable CSS and JS to be loaded inside a portlet. <%-- CSS, JS --%> <link href="/o/contact-us-portlet/css/portlet-main.css" rel="stylesheet" /> <script src="/o/contact-us-portlet/js/portlet-main.js"></script> The path starting with /o/(portlet-name)/  is automatically appended to main url (ex. localhost:8080/o/..) /o/(portlet-name)/  represents resources/META-INF/resources One thing to keep in mind is that the above initialization should be done after <liferay-theme:defineObjects /> <portlet:defineObjects /> I DO NOT KNOW WHY ... In view.jsp. can get path through request src="<%=request.getContextPath()%>/images/form-icon.png" Prerequisite: In bnd.bnd Web-ContextPath: /contact-us-portlet  should be set . ------------------------------------------------------------------------- Today's trouble sh
create Repo in Githup open git bash and go to project folder git init git add * git status git commit -m "message" git status git remote add origin https://github.com/claire-min/testRepo.git git push -u origin master
Update User Details Resource Method (Start with postman request example) 1. UpdateUser in controller 2. implement service layer 3. test with postman   LOGOIN -> PUT just firstname and lastname  -> GET Delete User Resource Method(Start with postman request example) 1. operationStatusModel   Response model 2. modify deleteuser in controller 3. RequestOperationName      enum  in controller pkg 4. RequestOperationStatus      enum in response pkg 5. service 6. postman test DELTE - GET 7. getUserByUserId in serviceimpl for exception message Get List of USers GET : localhost:8080/users?page=1&limit=50  (passed as url query string, not passed parameter) 1. controller getUSers 2. service 3. repository 4. postman LOGIN ->  GET with the above url   WITH or WITHOUT limit

Nov 21

* Update pom.xml, add xml and json media types to support returned information type 1. add dependency of dataformat xml 2. In controller, add produces to GetMapping / PostMapping GET Accept application/xml or json * How to handle exceptions (screenshot) 1. custom description message 2. modify createUser in controller 3. test POST request with empty names    json and xml * Create exception for each service class (Create UserService Exception) 1.create UserServiceException.java 2. modify exception to UserServiceException in createUser * How to handle this specific user service exception 1. create AppExceptionsHandler 2. test POST request and check response message without accept header 1. Create ErrorMessage.java 2. modify AppExceptionsHandler 3. test POST again * handle all other exceptions 1. add handleOtherExceptions method 2. modify createUser in controller 3. test POST Reference https://crunchify.com/why-and-for-what-should-i-use-enum-java-enum-e

my liferay

http://74.208.244.157:8080/

Git - Source control / Version Control

Clone : Remote repository  -=---->  Local repository (copying repo) 1. Clone your remote repo to your local system where to create local repo> git clone remoteURL 2. Add files to local repo & put it on remote repo > git status : how your project is progressing in comparison to you remote repo (file untracked ) > git add file.txt ---->  to track a file (move changes from the working directory to the Git staging area. The staging area is where you prepare a snapshot of a set of changes before committing them to the official history >git status > git commit -m  "message" : git commit takes the staged snapshot and commits it to the project history. --------------------------------------------------------------------------------------------------- on local system > git push origin master : specifies that you are pushing to the master branch on origin(server). Your commits are now on remote repo

Authentication vs. Authorization

Test Sign in /login *Add public User Id to a response header Access to userService bean from Authentication filter to get User Detail info 1. add SpringApplicationContext.java (to access bean anywhere)    and add its bean to main.java 2. add code under created token to include public user Id in header 3. implemnet getUser in service 4.finish filter 5. test signin with postman and check if there is userId in header Customize login url which trigger user authentication 1. WebSecurity -> getAuthenticationFilter() Implement Authorization filter -Test Put with token header and publicID Key : Authorization valu: headerstring + token and url is users/publicId 1. Create AuthorizationFilter When HTTP Request is made , doFilterInternal is triggered 2. add filter to webSecurity configure 3. test login and put request with authorization and not Make REST API Stateless remove http session from configure WebSecurity Read Token Secret value from proper

previous

Preventing duplicate entries 1.repo 2.service Generate secure public user ID 1.create component for utility classes 2.autowired util to serviceimpl Add spring security 1.add dependencies for spring boot security starter, jwt -- password Encrypt user provied password using spring boot security 1.main 2. autowired it to serviceimpl  (desc) -postman post test 401 Create Sing up method to create account 1.WebSecurity (userdetailservice) 2.extend userdetailservce from userservice and impl and modify websecuriy

Spring Security Issue

It is assumed that - errors in WebSecurity.java occured due to typo or incorrect package import. - failure of sending Http post request through Postman is caused as previous request created after endpoint change could not aceept the change for some reason. # What I did for fix - removed Spring security dependency to turn it back to previous state which has no authorization process. - tested request by creating new request in Postman * It is found that additional configuration (spring.datasource.url=jdbc:mysql://localhost:3306/test ?autoReconnect=true&useSSL=false ) does not affect server operation for now. --------------------------------------------------------------------------------------------------------------------- prerequisite : password field should be removed from UserEntity.java <!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-security --> <dependency> <groupId>org.springframework.boot</gro