Package com.liferay.portal.service

Examples of com.liferay.portal.service.ServiceContext


    throws Exception {

    String className = (String) message.get("className");
    String keywords = (String) message.get("keywords");

    ServiceContext serviceContext = (ServiceContext) message.get("serviceContext");

    serviceContext.setUserId(serviceContext.getUserId());

    NotFoundLocalServiceUtil.addNotFound(className, keywords, serviceContext);
  }
View Full Code Here


public class GuestbookPortlet extends MVCPortlet {

  public void addEntry(ActionRequest request, ActionResponse response)
      throws PortalException, SystemException {

    ServiceContext serviceContext = ServiceContextFactory.getInstance(
        Entry.class.getName(), request);

    String userName = ParamUtil.getString(request, "name");
    String email = ParamUtil.getString(request, "email");
    String message = ParamUtil.getString(request, "message");
    long guestbookId = ParamUtil.getLong(request, "guestbookId");

    try {
      EntryLocalServiceUtil.addEntry(serviceContext.getUserId(),
          guestbookId, userName, email, message, serviceContext);

      SessionMessages.add(request, "entryAdded");

      response.setRenderParameter("guestbookId",
View Full Code Here

  }

  public void addGuestbook(ActionRequest request, ActionResponse response)
      throws PortalException, SystemException {

    ServiceContext serviceContext = ServiceContextFactory.getInstance(
        Guestbook.class.getName(), request);

    String name = ParamUtil.getString(request, "name");

    try {
      GuestbookLocalServiceUtil.addGuestbook(serviceContext.getUserId(),
          name, serviceContext);

      SessionMessages.add(request, "guestbookAdded");

    } catch (Exception e) {
View Full Code Here

  @Override
  public void render(RenderRequest renderRequest,
      RenderResponse renderResponse) throws PortletException, IOException {

    try {
      ServiceContext serviceContext = ServiceContextFactory.getInstance(
          Guestbook.class.getName(), renderRequest);

      long groupId = serviceContext.getScopeGroupId();

      long guestbookId = ParamUtil.getLong(renderRequest, "guestbookId");

      List<Guestbook> guestbooks = GuestbookLocalServiceUtil
          .getGuestbooks(groupId);

      if (guestbooks.size() == 0) {
        Guestbook guestbook = GuestbookLocalServiceUtil.addGuestbook(
            serviceContext.getUserId(), "Main", serviceContext);

        guestbookId = guestbook.getGuestbookId();

      }
View Full Code Here

      addLayout(privateLayout, parentLayoutId, layoutJSONObject);
    }
  }

  protected void doImportResources() throws Exception {
    serviceContext = new ServiceContext();

    serviceContext.setAddGroupPermissions(true);
    serviceContext.setAddGuestPermissions(true);
    serviceContext.setScopeGroupId(groupId);
View Full Code Here

      layoutSetPrototype);
  }

  protected void setupSitemap(String fileName) throws Exception {
    LayoutLocalServiceUtil.deleteLayouts(
      groupId, true, new ServiceContext());

    LayoutLocalServiceUtil.deleteLayouts(
      groupId, false, new ServiceContext());

    JSONObject jsonObject = getJSONObject(fileName);

    if (jsonObject == null) {
      return;
View Full Code Here

      }
      else {
        layoutSetPrototype =
          LayoutSetPrototypeLocalServiceUtil.addLayoutSetPrototype(
            userId, companyId, getTargetValueMap(),
            StringPool.BLANK, true, true, new ServiceContext());
      }

      group = layoutSetPrototype.getGroup();

      targetClassPK = layoutSetPrototype.getLayoutSetPrototypeId();
    }
    else if (targetClassName.equals(Group.class.getName())) {
      if (targetValue.equals(GroupConstants.GUEST)) {
        group = GroupLocalServiceUtil.getGroup(
          companyId, GroupConstants.GUEST);

        List<Layout> layouts = LayoutLocalServiceUtil.getLayouts(
          group.getGroupId(), false,
          LayoutConstants.DEFAULT_PARENT_LAYOUT_ID, false, 0, 1);

        if (!layouts.isEmpty()) {
          Layout layout = layouts.get(0);

          LayoutTypePortlet layoutTypePortlet =
            (LayoutTypePortlet)layout.getLayoutType();

          List<String> portletIds = layoutTypePortlet.getPortletIds();

          if (portletIds.size() != 2) {
            existing = true;
          }

          for (String portletId : portletIds) {
            if (!portletId.equals("47") &&
              !portletId.equals("58")) {

              existing = true;
            }
          }
        }
      }
      else {
        group = GroupLocalServiceUtil.fetchGroup(
          companyId, targetValue);

        if (group != null) {
          existing = true;
        }
        else {
          group = GroupLocalServiceUtil.addGroup(
            userId, GroupConstants.DEFAULT_PARENT_GROUP_ID,
            StringPool.BLANK,
            GroupConstants.DEFAULT_PARENT_GROUP_ID,
            GroupConstants.DEFAULT_LIVE_GROUP_ID, targetValue,
            StringPool.BLANK, GroupConstants.TYPE_SITE_OPEN, true,
            GroupConstants.DEFAULT_MEMBERSHIP_RESTRICTION, null,
            true, true, new ServiceContext());
        }
      }

      targetClassPK = group.getGroupId();
    }
View Full Code Here

        if (amPm == Calendar.PM) {
            hour += 12;
        }

        ServiceContext serviceContext = ServiceContextFactory.getInstance(
            Event.class.getName(), request);

        Event event = null;

        if (eventId <= 0) {
            event = EventLocalServiceUtil.addEvent(
                serviceContext.getUserId(), serviceContext.getScopeGroupId(),
                name, description, month, day, year, hour, minute, locationId,
                serviceContext);
        }
        else {
            event = EventLocalServiceUtil.getEvent(eventId);

            event = EventLocalServiceUtil.updateEvent(
                serviceContext.getUserId(), eventId, name, description, month,
                day, year, hour, minute, locationId, serviceContext);
        }

        return event;
    }
View Full Code Here

        String streetAddress = (ParamUtil.getString(request, "streetAddress"));
        String city = (ParamUtil.getString(request, "city"));
        String stateOrProvince = (ParamUtil.getString(request, "stateOrProvince"));
        String country = (ParamUtil.getString(request, "country"));

        ServiceContext serviceContext = ServiceContextFactory.getInstance(
                Location.class.getName(), request);

        Location location = null;

        if (locationId <= 0) {

            location = LocationLocalServiceUtil.addLocation(
                serviceContext.getUserId(), serviceContext.getScopeGroupId(), name, description,
                streetAddress, city, stateOrProvince, country, serviceContext);
        }
        else {
            location = LocationLocalServiceUtil.getLocation(locationId);

            location = LocationLocalServiceUtil.updateLocation(
                    serviceContext.getUserId(), locationId, name,
                    description, streetAddress, city, stateOrProvince, country,
                    serviceContext);
        }

        return location;
View Full Code Here

  }

  private static void _localizeRoleNames(long companyId, String languageId)
    throws Exception {

    ServiceContext serviceContext = new ServiceContext();

    // Regular roles

    for (String name : PortalUtil.getSystemRoles()) {
      Role role = RoleLocalServiceUtil.loadGetRole(companyId, name);
View Full Code Here

TOP

Related Classes of com.liferay.portal.service.ServiceContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.