Wednesday, 9 October 2013

Deploying The Themes In Liferay

Deploying The Themes In Liferay


Step 1: Take the zip file of two themes and extract the zip file.

Step 2: Place these two themes (1.Liferay_New-theme) in
Pluginsà themes folder of your liferay 6.1 GA2 workspace.

Step 3: Import the two themes into Eclipse IDE.
a. Click on liferay plugins in IDE and select “New Liferay Project From Existing Source”.
b. And browse you liferay workspace pluginsàthemes folder and select the respected theme (Liferay_New-theme).

Step 4: Explore the Liferay_New-theme and drag and drop the build.xml to ant view in eclipse ide.

Step 5: Expand the Liferay_New-theme in ant view and run the deploy (by double clicking on deploy option).

Step 6: Observe the console until build successful and 1 theme is available for use.

Step 7: Explore the Liferay_Pages-theme and drag and drop the build.xml to ant view in eclipse ide.

Step 8: Expand the Liferay_Pages-theme in ant view and run the deploy (by double clicking on deploy option).

Step 9: Observe the console until build successful and 1 theme is available for use.

Sending Email Via Gmail Using Java Mail API

Sending Email Via Gmail Using Java Mail API

import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class SendMailTLS {
 public static void main(String[] args) {
 
  // To address
  String to = "to_mail@gmail.com";
  // If any CC email ids
  String cc = "cc@mail.com";
  // If any BCC email ids
  String bcc = "bcc@mail.com";
  // Email Subject
  String subject = "Java Discover";
  // Email content
  String emailText = "Hi All, Welcome to Java Mail API";

  // Sending Email using Gmail SMTP
  sendEmail(to, cc, bcc, subject, emailText);
 }

 public static void sendEmail(String to, String cc, String bcc, String subject, String emailText) {
 
  // From address (Need Gmail ID)
  String from = "from_mail@gmail.com";
  // Password of from address
  String password = "from_password";
  // Gmail host address
  String host = "smtp.gmail.com";
 
  Properties props = System.getProperties();
  props.put("mail.smtp.host", host);
  props.put("mail.smtp.socketFactory.port", "465");
  props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
  props.put("mail.smtp.auth", "true");
  props.put("mail.smtp.port", "465");
  props.put("mail.smtp.user", from);
  props.put("password", password);

  Session session = Session.getDefaultInstance(props, null);

  MimeMessage msg = new MimeMessage(session);
  try {
   msg.setFrom(new InternetAddress(from));
  
   // Adding To address
   msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to,false));
   // Adding CC email id
   msg.setRecipients(Message.RecipientType.CC, InternetAddress.parse(cc,false));
   // Adding BCC email id
   msg.setRecipients(Message.RecipientType.BCC, InternetAddress.parse(bcc, false));

   msg.setSubject(subject);
   msg.setText(emailText);
  
   Transport transport = session.getTransport("smtp");
   transport.connect(host, from, password);
   transport.sendMessage(msg, msg.getAllRecipients());
   transport.close();
  
   System.out.println("Email was sent successfully.....");
  
  } catch (AddressException e) {
   e.printStackTrace();
  } catch (MessagingException e) {
   e.printStackTrace();
  }
 }

}

alljobs blog for u

Tuesday, 8 October 2013

Liferay Consumer Survey | Liferay Solutions - A Complete Liferay development support

Liferay Consumer Survey | Liferay Solutions - A Complete Liferay development support

Where Liferay Fits In

Where Liferay Fits In

You may be wondering where Liferay fits into your existing ecosystem. The key thing to remember is this: Liferay is a Java web
application, running on a standard Java servlet container or application server. Since the choice of app server does not matter for IdM,
we will use Liferay on Apache Tomcat as an example.
Here is a typical Liferay installation:
Figure 1
In Figure 1, it is apparent that Liferay thrives in this ecosystem. In this example, Liferay is relying on its own authentication mechanism.
Here is a typical Liferay installation, with LDAP:
Figure 2
In Figure 2, Liferay is using LDAP as its one true source of authentication. The portal no longer relies on the user information in the
Liferay database but on the user credentials stored in the LDAP server. For Microsoft Active Directory, Figure 2 applies as well. In this
setup, the user ID and passwords are managed from the LDAP server along with the tools that are associated with it. Many organizations
either have a separate password reset or administration page or need to call their IT departments to reset or administer their password.
In either case, Liferay does not know anything about these tools. It simply binds to the LDAP server and verifies whether the user has
provided valid credentials in the portal.
LDAP Authentication
LDAP Import
Liferay
Database
LDAP
API
Database
Liferay
Authentication


By default, once authenticated and the user’s session is created, the user’s basic credentials (username, password, email address, first
name, last name, title) are all imported into the Liferay database in a one-way sync. This happens every time a user performs a login.
There is also the option to configure Liferay Portal to do a two-way sync (export). The two-way sync allows users to change their
information from within the portal and have it sync outwardly to the LDAP server. The synchronizations can happen real-time or be set
to a time interval. If you wish to have the LDAP server be the central point of administration, it is recommended that you do not turn on
the two-way sync, allowing the LDAP server to remain as the one true source of authentication at all times.
Here is a typical Liferay Installation, with SS O and LDAP:
Figure 3
In Figure 3, Liferay Portal is relying on the SS O server to broker the authentication, with LDAP storing the user data. Figure 3
demonstrates that even though the SS O server is responsible for authentication, that user’s identity is still stored in the LDAP server. The
SS O server will use one of a variety of authentication mechanisms. These include cookies, tokens, and agents. Whatever implementation
is used, the SS O server will simply authenticate and allow you a session. It will not give complete user identity to the portal. In Figure 3,
the user is authenticated by the SS O server, but after authentication, the user’s information is imported into the portal from LDAP. In this

sort of system, other applications can leverage your SS O server without requiring LDAP on those systems. In Figure 2, if you wanted to use LDAP as your central IdM server, this would require that all your web applications are able to connect to your LDAP server.

Inter portlet communication

Inter portlet communication

Hello Everyone,
Here is the flow of IPC



Here below are the steps to follow for IPC :



Sender portlet

To configure a portlet to be available to send events, add the following to your portlet.xml:

First, you have to define the event to send.
To do this, you need to specify a namespace and a name for your event. 
This definition is the event definition that has to go into the portlet.xml of the sender AND of all receivers.
In our case it defines, that an event called "message" for the namespace http:your.private.namespace.com/yourEvent exists which is a String

<event-definition>
<qname xmlns:t="http:your.private.namespace.com/yourEvent">t:message</qname>
<value-type>java.lang.String</value-type>
</event-definition>

To choose your portlet as a sending portlet additionally add the following:

<supported-publishing-event>
   <qname xmlns:u="http:your.private.namespace.com/yourEvent">t:message</qname>
</supported-publishing-event>

This selects your portlet as a sending portlet for the chosen event.
This is all for the configuration of the sender portlet.
 Now let´s write code to send an event in sender class.

public void sendEvent(ActionRequest actionRequest,ActionResponse actionResponse) {
QName qname = new QName(“http:your.private.namespace.com/yourEvent","message");
actionResponse.setEvent(qname,"Hello World");
return;
}


Receiver portlet

First add the event definition to the portlet.xml of your receiving portlet.

<event-definition>
<qname xmlns:t="http:your.private.namespace.com/yourEvent">t:message</qname>
<value-type>java.lang.String</value-type>
</event-definition>

Second, add tis code to process an event

<supported-processing-event>
<qname xmlns:u="http:your.private.namespace.com/yourEvent">t:message</qname>
</supported-processing-event>

Now, just write code to your receiving portlet class,

@Override
public void processEvent(EventRequest request, EventResponse response)
{
Event event = request.getEvent();
if (event.getName().equals("message"))
{
String  message = (String) event.getValue();
}
}