Posts

How to find the companyId in Liferay.

In liferay many services require comapanyId. In lifeay company means portal instance. You can find this easily. Get comapanyId in code: PortalUtil.getDefaultCompanyId(); this give you default companyId. PortalUtil.getCompanyId(request); here request means HttpServletRequest. PortalUtil.getCompanyId(portletRequest);here portletRequest means any portletRequest(Render,Action or Resource).  ThemeDisplay themeDisplay=(ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);themeDisplay.getCompanyId();  Get current companyId from specific thread local storage by:             CompanyThreadLocal.getCompanyId(); Get comapanyId manually: To find the company ID (portal instance ID), follow these steps: 1/ Sign into portal as admin user 2/ Navigation the Portal Instances admin page Navigation Path is "Dockbar > Admin > Control Panel > (Configuration) Portal Instances 3/ Review first column  "Instance ID" The i...

How to set ant_opts in ubuntu

Edit ~/.bashrc Open terminal and execute> $ sudo gedit .bashrc Above command open .bashrc file in edit mode. Now add the below two lines: ANT_OPTS="-Xmx1024m -XX:MaxPermSize=256m" export ANT_OPTS Now save the file and close terminal. Enjoy......

How to make Back Up and Restore from backup in MySQL Database.

In this tutorial i will show you easy ways to backup and restore the data in your MySQL database. Back up From the Command Line:   Here is the proper  syntax to backup in command> $ mysqldump --opt -u [uname] -p[pass] [dbname] > [backupfile.sql] Here: [uname] Your database username [pass] The password for your database (note there is no space between -p and the password) [dbname] The name of your database [backupfile.sql] The filename for your database backup [--opt] The mysqldump option  For example, to backup a database named 'ranger' with the username 'root' and with password 'root' to a file ranger_backup.sql, using command: $ mysqldump -uroot -proot ranger > ranger_backup.sql   Above command store your back file in home directory. If you want to backup in specific directory then go to your desired directory and execute the above command.   With mysqldump command you can specify certain tables of ...

How disable anonymous access to MongoDB OR Enable Client Access Control in MongoDB.

Securing MongoDB with Authentication and Authorization: Step 1) Login using shell and Create an admin account: Open terminal and login using below command>  mongo  Switch to admin db using below command> use admin;    Create Admin user using below command> db.createUser({ user : "admin", pwd : "pass", roles: [ { role: 'root', db: 'admin' } ] });   Now Give grand Roles to Admin User using below command:   db.grantRolesToUser( " admin ", [{ "role" : "readWriteAnyDatabase", "db" : "admin" },{ role: "userAdminAnyDatabase", db: "admin" }] ) Step 2) Test your admin account using below command> mongo -u admin -p pass --authenticationDatabase admin   Step 4) Force authorization  FOR MONGODB 3.0 AND ABOVE add these lines in /etc/mongod.conf>  security:   authorization: enabled FOR MONGO...

How to install mongodb in ubuntu 15.04

Step 1: If you install any packages of mongodb yet, firstly remove all. To remove all existing packages execute the below command: sudo apt-get purge mongodb-org sudo apt-get autoremove Remove the old mongodb source list you created in below folder. sudo rm /etc/apt/sources.list.d/   Remove db and logs: sudo rm -r /var/lib/mongodb sudo rm -r /var/log/mongodb Step 2: Add debian repository: echo "deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.0 main" |  sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list   Step 3: Update and install: sudo apt-get update sudo apt-get install -y mongodb-org Step 4: Start mongo db: sudo service mongod start or systemctl start mongod  Step 5: Configure MongoDB username and password: open mongo shell : (cntrl+alt+t) open termianl and type > mongo   then the shell is open. then switch the database typing> use admin then Create the r...

Reverse-Proxy in apache2.

Follow the below blog. How To Use Apache HTTP Server As Reverse-Proxy Using mod_proxy Extension.

Set Up Apache Virtual Hosts on Ubuntu.

Prerequisites: You have to install apache2 in your os. For this follow my previous blog Install apache2 in Ubuntu.   Step 1: Create new host. Open terminal(ctrl+alt+t) and paste below code > sudo gedit /etc/hosts Now edit the file. Means add new host name and port.Example add below line > 127.0.1.1    example.com Now save and close the file. Step 2: Create the Directory Structure. Create new folder in /var/www/    directory . For this execute the below line> sudo mkdir -p /var/www/ example.com /public_html   Step 3:  Grant Permissions.Now change permissions to enable regular user to modify files in our web directories. For this execute the below line> sudo chown -R $USER:$USER /var/www/ example.com /public_html   We should also modify our permissions a little bit to ensure that read access is permitted to the general web directory. For this execute the below line > sudo chmod -R ...