Example usage for com.liferay.portal.kernel.messaging Message getDestinationName

List of usage examples for com.liferay.portal.kernel.messaging Message getDestinationName

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.messaging Message getDestinationName.

Prototype

public String getDestinationName() 

Source Link

Usage

From source file:com.liferay.osb.scv.user.mapper.internal.messaging.UserMapperMessageListener.java

License:Open Source License

@Override
@SuppressWarnings("unchecked")
protected void doReceive(Message message) throws Exception {
    String responseId = message.getResponseId();

    Event event = EventManager.getEvent(responseId);

    if (event != null) {
        event.handleResponse(message);/*from w  w  w  .  j  a  v a 2s.co m*/

        return;
    }

    String method = message.getString("method");
    long mappingDataSourceId = message.getLong("mappingDataSourceId");

    if (method.equals("addData")) {
        List<UserMappingRule> userMappingRules = null;

        MappingDataSource mappingDataSource = MappingDataSourceLocalServiceUtil
                .fetchMappingDataSource(mappingDataSourceId);

        if (mappingDataSource.getType() == MappingDataSourceConstants.CUSTOM) {

            userMappingRules = UserMappingRuleLocalServiceUtil.getUserMappingRules(mappingDataSourceId);
        } else {
            userMappingRules = UserMappingRuleLocalServiceUtil.getUserMappingRules(mappingDataSourceId,
                    FrequencyUtil.INSTANT);
        }

        event = new UpdateUsersEvent(mappingDataSourceId, userMappingRules);

        event.handleResponse(message);
    } else if (method.equals("addDataSource")) {
        String name = message.getString("name");
        String url = message.getString("url");

        long type = MappingDataSourceConstants.CUSTOM;

        if (!Validator.isBlank(url)) {
            type = MappingDataSourceConstants.LIFERAY;
        }

        String login = message.getString("login");
        String password = message.getString("password");
        String availableFields = message.getString("availableFields");

        MappingDataSource mappingDataSource = MappingDataSourceServiceUtil.addMappingDataSource(name, url,
                login, password, type, availableFields);

        Message responseMessage = MessageBusUtil.createResponseMessage(message);

        responseMessage.setPayload(mappingDataSource.getMappingDataSourceId());

        MessageBusUtil.sendMessage(responseMessage.getDestinationName(), responseMessage);
    } else if (method.equals("addUserMappingRule")) {
        String modelName = message.getString("modelName");
        String sourceField = message.getString("sourceField");
        String destinationField = message.getString("destinationField");

        UserMappingRuleServiceUtil.addUserMappingRule(mappingDataSourceId, 0, modelName, sourceField,
                destinationField, FrequencyUtil.ONCE, false);
    } else if (method.equals("getFields")) {
        GetFieldsEvent getFieldsEvent = new GetFieldsEvent(mappingDataSourceId);

        getFieldsEvent.run();
    }
}

From source file:com.rivetlogic.geo.util.GeoMessageListener.java

License:Open Source License

public void receive(Message message) {
    try {/*from   w  w w  .  j  a  v  a 2  s.  com*/
        if (message.getDestinationName().equals(GeoServicesPortletConstants.MESSAGE_DESTINATION)) {
            doReceive(message);
        } else if (message.getDestinationName().equals(GeoServicesPortletConstants.MESSAGE_RESPONSE)) {
            doReceiveResponse(message);
        }
    } catch (IOException e) {
        LOG.error(GeoServicesPortletConstants.ERROR_PROCESSING_MESSAGE, e);
    }
}

From source file:com.rivetlogic.geoip.util.GeoipMessageListener.java

License:Open Source License

public void receive(Message message) {
    try {//w w  w .j  a  va2 s  . co  m
        if (message.getDestinationName().equals(IPGeoServicesPortletConstants.MESSAGE_DESTINATION)) {
            doReceive(message);
        } else if (message.getDestinationName().equals(IPGeoServicesPortletConstants.MESSAGE_RESPONSE)) {
            doReceiveResponse(message);
        }
    } catch (IOException e) {
        LOG.error(IPGeoServicesPortletConstants.ERROR_PROCESSING_MESSAGE, e);
    }
}

From source file:de.uhh.l2g.plugins.util.PortletScheduler.java

License:Open Source License

@Override
public void receive(Message message) throws MessageListenerException {
    String values = "No values";
    // Debug Information on running job
    if (message != null) {
        LOG.info("Message :" + message.toString());
        Thread thread = Thread.currentThread();
        LOG.info("Thread :" + thread.getContextClassLoader());
        LOG.info("Thread :" + thread.toString());
        Map<String, Object> map = message.getValues();
        LOG.info(message.get(SchedulerEngine.DESTINATION_NAME) + " " + message.getDestinationName() + " "
                + message.getValues().get(SchedulerEngine.DESTINATION_NAME) + " "
                + message.getDestinationName());
        values = map.toString();// w  ww  . ja  va2 s.co m
    }
    LOG.info("Portlet Scheduler running... " + values);
}

From source file:it.dontesta.liferay.messagebus.example.mvc.SendEmail.java

License:Open Source License

/**
 * Send a list of no active user by Email Sender
 * /*from  w  w w .jav a 2s.  c om*/
 * @param actionRequest
 * @param actionResponse
 * @throws IOException
 * @throws PortletException
 * @throws SystemException
 */
public void sendEmailByEmailSender(ActionRequest actionRequest, ActionResponse actionResponse)
        throws IOException, PortletException, SystemException {
    User user = (User) actionRequest.getAttribute(WebKeys.USER);

    List<User> userList = getInactiveUsers(user);
    String emailBody = getEmailBody(userList);

    if (userList.size() > 0) {
        InternetAddress from = new InternetAddress("noreply@liferay.com", "Liferay Portale");
        InternetAddress to = new InternetAddress(user.getEmailAddress(), user.getFullName());

        MailMessage message = new MailMessage(from, to, "List of disabled users", emailBody, false);

        Message myMessage = new Message();
        myMessage.setDestinationName(DestinationNames.MAIL);
        myMessage.setPayload(message);
        MessageBusUtil.sendMessage(myMessage.getDestinationName(), myMessage);

        SessionMessages.add(actionRequest, "email-userlist-no-active-send-successfully");
    } else {
        SessionErrors.add(actionRequest, "email-userlist-no-active-count-zero");
    }

}