/**
   * Converts the soap model instance into a normal model instance.
   *
   * @param soapModel the soap model instance to convert
   * @return the normal model instance
   */
  public static Group toModel(GroupSoap soapModel) {
    if (soapModel == null) {
      return null;
    }

    Group model = new GroupImpl();

    model.setUuid(soapModel.getUuid());
    model.setGroupId(soapModel.getGroupId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setCreatorUserId(soapModel.getCreatorUserId());
    model.setClassNameId(soapModel.getClassNameId());
    model.setClassPK(soapModel.getClassPK());
    model.setParentGroupId(soapModel.getParentGroupId());
    model.setLiveGroupId(soapModel.getLiveGroupId());
    model.setTreePath(soapModel.getTreePath());
    model.setName(soapModel.getName());
    model.setDescription(soapModel.getDescription());
    model.setType(soapModel.getType());
    model.setTypeSettings(soapModel.getTypeSettings());
    model.setFriendlyURL(soapModel.getFriendlyURL());
    model.setSite(soapModel.getSite());
    model.setActive(soapModel.getActive());

    return model;
  }
Esempio n. 2
0
  protected void setPortletScope(PortletDataContext portletDataContext, Element portletElement) {

    // Portlet data scope

    String scopeLayoutUuid =
        GetterUtil.getString(portletElement.attributeValue("scope-layout-uuid"));
    String scopeLayoutType =
        GetterUtil.getString(portletElement.attributeValue("scope-layout-type"));

    portletDataContext.setScopeLayoutUuid(scopeLayoutUuid);
    portletDataContext.setScopeType(scopeLayoutType);

    // Layout scope

    try {
      Group scopeGroup = null;

      if (scopeLayoutType.equals("company")) {
        scopeGroup = GroupLocalServiceUtil.getCompanyGroup(portletDataContext.getCompanyId());
      } else if (Validator.isNotNull(scopeLayoutUuid)) {
        Layout scopeLayout =
            LayoutLocalServiceUtil.getLayoutByUuidAndGroupId(
                scopeLayoutUuid, portletDataContext.getGroupId());

        if (scopeLayout.hasScopeGroup()) {
          scopeGroup = scopeLayout.getScopeGroup();
        } else {
          String name = String.valueOf(scopeLayout.getPlid());

          scopeGroup =
              GroupLocalServiceUtil.addGroup(
                  portletDataContext.getUserId(null),
                  Layout.class.getName(),
                  scopeLayout.getPlid(),
                  name,
                  null,
                  0,
                  null,
                  false,
                  true,
                  null);
        }

        Group group = scopeLayout.getGroup();

        if (group.isStaged() && !group.isStagedRemotely()) {
          try {
            Layout oldLayout =
                LayoutLocalServiceUtil.getLayoutByUuidAndGroupId(
                    scopeLayoutUuid, portletDataContext.getSourceGroupId());

            Group oldScopeGroup = oldLayout.getScopeGroup();

            oldScopeGroup.setLiveGroupId(scopeGroup.getGroupId());

            GroupLocalServiceUtil.updateGroup(oldScopeGroup, true);
          } catch (NoSuchLayoutException nsle) {
            if (_log.isWarnEnabled()) {
              _log.warn(nsle);
            }
          }
        }

        portletDataContext.setScopeGroupId(scopeGroup.getGroupId());
      }
    } catch (PortalException pe) {
    } catch (Exception e) {
      _log.error(e, e);
    }
  }