Package com.liferay.portal.model

Examples of com.liferay.portal.model.Portlet


//      groupId = _SHARED_KEY;
//    }

    PortletPK pk = new PortletPK(portletId, groupId, companyId);

    Portlet portlet = null;

    try {
      portlet = PortletUtil.findByPrimaryKey(pk);
    }
    catch (NoSuchPortletException nspe) {
      portlet = PortletUtil.create(pk);
    }

    portlet.setDefaultPreferences(defaultPreferences);
    portlet.setNarrow(narrow);
    portlet.setRoles(roles);
    portlet.setActive(active);

    PortletUtil.update(portlet);

    portlet = getPortletById(companyId, groupId, portletId);

    portlet.setDefaultPreferences(defaultPreferences);
    portlet.setNarrow(narrow);
    portlet.setRoles(roles);
    portlet.setActive(active);

    return portlet;
  }
View Full Code Here


      portletIds = CollectionFactory.getHashMap();

      Iterator itr = _getPortletsPool().values().iterator();

      while (itr.hasNext()) {
        Portlet portlet = (Portlet)itr.next();

        portletIds.put(portlet.getStrutsPath(), portlet.getPortletId());
      }

      SimpleCachePool.put(scpId, portletIds);
    }
View Full Code Here

      }

      Iterator itr = parentPortletsPool.values().iterator();

      while (itr.hasNext()) {
        Portlet portlet = (Portlet)((Portlet)itr.next()).clone();

        portlet.setGroupId(groupId);
        portlet.setCompanyId(companyId);

        portletsPool.put(portlet.getPortletId(), portlet);
      }

      itr = PortletUtil.findByG_C(groupId, companyId).iterator();

      while (itr.hasNext()) {
        Portlet portlet = (Portlet)itr.next();

        Portlet portletModel =
          (Portlet)portletsPool.get(portlet.getPortletId());

        // Portlet may be null if it exists in the database but its
        // portlet WAR is not yet loaded

        if (portletModel != null) {
          portletModel.setDefaultPreferences(
            portlet.getDefaultPreferences());
          portletModel.setNarrow(portlet.getNarrow());
          portletModel.setRoles(portlet.getRoles());
          portletModel.setActive(portlet.getActive());
        }
      }

      companyPortletsPool.put(cppId, portletsPool);
    }
View Full Code Here

          portletId;
      }

      portletIds.add(portletId);

      Portlet portletModel = (Portlet)portletsPool.get(portletId);
      if (portletModel == null) {
        portletModel = new Portlet(
          new PortletPK(portletId, _SHARED_KEY, _SHARED_KEY));

        portletsPool.put(portletId, portletModel);
      }

      if (servletContextName != null) {
        portletModel.setWARFile(true);
      }

      portletModel.setPortletClass(portlet.elementText("portlet-class"));

      Iterator itr2 = portlet.elements("init-param").iterator();

      while (itr2.hasNext()) {
        Element initParam = (Element)itr2.next();

        portletModel.getInitParams().put(
          initParam.elementText("name"),
          initParam.elementText("value"));
      }

      Element expirationCache = portlet.element("expiration-cache");
      if (expirationCache != null) {
        portletModel.setExpCache(new Integer(GetterUtil.getInteger(
          expirationCache.getText())));
      }

      itr2 = portlet.elements("supports").iterator();

      while (itr2.hasNext()) {
        Element supports = (Element)itr2.next();

        String mimeType = supports.elementText("mime-type");

        Iterator itr3 = supports.elements("portlet-mode").iterator();

        while (itr3.hasNext()) {
          Element portletMode = (Element)itr3.next();

          Set mimeTypeModes =
            (Set)portletModel.getPortletModes().get(mimeType);

          if (mimeTypeModes == null) {
            mimeTypeModes = new HashSet();

            portletModel.getPortletModes().put(
              mimeType, mimeTypeModes);
          }

          mimeTypeModes.add(portletMode.getTextTrim().toLowerCase());
        }
      }

      Set supportedLocales = portletModel.getSupportedLocales();

      supportedLocales.add(Locale.getDefault().getLanguage());

      itr2 = portlet.elements("supported-locale").iterator();

      while (itr2.hasNext()) {
        Element supportedLocaleEl = (Element)itr2.next();

        String supportedLocale = supportedLocaleEl.getText();

        supportedLocales.add(supportedLocale);
      }

      portletModel.setResourceBundle(
        portlet.elementText("resource-bundle"));

      Element portletInfo = portlet.element("portlet-info");

      String portletInfoTitle = null;
      String portletInfoShortTitle = null;
      String portletInfoKeyWords = null;

      if (portletInfo != null) {
        portletInfoTitle = portletInfo.elementText("title");
        portletInfoShortTitle = portletInfo.elementText("short-title");
        portletInfoKeyWords = portletInfo.elementText("keywords");
      }

      portletModel.setPortletInfo(new PortletInfo(
        portletInfoTitle, portletInfoShortTitle, portletInfoKeyWords));

      Element portletPreferences = portlet.element("portlet-preferences");

      String defaultPreferences = null;
      String prefsValidator = null;

      if (portletPreferences != null) {
        Element prefsValidatorEl =
          portletPreferences.element("preferences-validator");

        String prefsValidatorName = null;

        if (prefsValidatorEl != null) {
          prefsValidator = prefsValidatorEl.getText();

          portletPreferences.remove(prefsValidatorEl);
        }

        ByteArrayOutputStream baos = new ByteArrayOutputStream();

        XMLWriter writer = new XMLWriter(
          baos, OutputFormat.createCompactFormat());

        writer.write(portletPreferences);

        defaultPreferences = baos.toString();
      }

      portletModel.setDefaultPreferences(defaultPreferences);
      portletModel.setPreferencesValidator(prefsValidator);

      if (!portletModel.isWARFile() &&
        Validator.isNotNull(prefsValidator) &&
        GetterUtil.getBoolean(PropsUtil.get(
          PropsUtil.PREFERENCE_VALIDATE_ON_STARTUP))) {

        try {
          PreferencesValidator prefsValidatorObj =
            PortalUtil.getPreferencesValidator(portletModel);

          prefsValidatorObj.validate(
            PortletPreferencesSerializer.fromDefaultXML(
              defaultPreferences));
        }
        catch (Exception e) {
          _log.warn(
            "Portlet with the name " + portletId +
              " does not have valid default preferences");
        }
      }

      List roles = new ArrayList();

      itr2 = portlet.elements("security-role-ref").iterator();

      while (itr2.hasNext()) {
        Element role = (Element)itr2.next();

        roles.add(role.elementText("role-name"));
      }

      portletModel.setRolesArray((String[])roles.toArray(new String[0]));

      portletModel.getUserAttributes().addAll(userAttributes);
    }

    return portletIds;
  }
View Full Code Here

    List undefinedPortlets = new ArrayList();

    itr1 = _getPortletsPool().values().iterator();

    while (itr1.hasNext()) {
      Portlet portlet = (Portlet)itr1.next();

      String portletId = portlet.getPortletId();

      if ((servletContextName != null) && (portlet.isWARFile()) &&
        (portletId.startsWith(servletContextName) &&
        (!portletIds.contains(portletId)))) {

        undefinedPortlets.add(new KeyValuePair(portletId, null));
      }
      else if ((servletContextName == null) && (!portlet.isWARFile()) &&
           (!portletIds.contains(portletId))) {

        undefinedPortlets.add(new KeyValuePair(portletId, null));
      }
    }
View Full Code Here

          portletId;
      }

      liferayPortletIds.add(portletId);

      Portlet portletModel = (Portlet)portletsPool.get(portletId);

      if (portletModel != null) {
        portletModel.setStrutsPath(GetterUtil.get(
          portlet.attributeValue("struts-path"),
          portletModel.getStrutsPath()));
        portletModel.setIndexerClass(GetterUtil.get(
          portlet.attributeValue("indexer-class"),
          portletModel.getIndexerClass()));
        portletModel.setSchedulerClass(GetterUtil.get(
          portlet.attributeValue("scheduler-class"),
          portletModel.getSchedulerClass()));
        portletModel.setPreferencesSharingType(GetterUtil.get(
          portlet.attributeValue("preferences-sharing-type"),
          portletModel.getPreferencesSharingType()));
        portletModel.setUseDefaultTemplate(GetterUtil.get(
          portlet.attributeValue("use-default-template"),
          portletModel.isUseDefaultTemplate()));
        portletModel.setShowPortletAccessDenied(GetterUtil.get(
          portlet.attributeValue("show-portlet-access-denied"),
          portletModel.isShowPortletAccessDenied()));
        portletModel.setShowPortletInactive(GetterUtil.get(
          portlet.attributeValue("show-portlet-inactive"),
          portletModel.isShowPortletInactive()));
        portletModel.setRestoreCurrentView(GetterUtil.get(
          portlet.attributeValue("restore-current-view"),
          portletModel.isRestoreCurrentView()));
        portletModel.setNs4Compatible(GetterUtil.get(
          portlet.attributeValue("ns-4-compatible"),
          portletModel.isNs4Compatible()));
        portletModel.setNarrow(GetterUtil.get(
          portlet.attributeValue("narrow"),
          portletModel.isNarrow()));
        portletModel.setActive(GetterUtil.get(
          portlet.attributeValue("active"),
          portletModel.isActive()));
        portletModel.setInclude(GetterUtil.get(
          portlet.attributeValue("include"),
          portletModel.isInclude()));

        portletModel.getCustomUserAttributes().putAll(
          customUserAttributes);
      }
    }

    return liferayPortletIds;
View Full Code Here

    String cmd = req.getParameter(Constants.CMD);
 
    if( (cmd != null && cmd.equals(Constants.UPDATE)) ) {
      String portletId = ParamUtil.getString(req, "portlet_id");
      String groupId = ParamUtil.getString(req, "group_id");
      Portlet portlet = PortletManagerUtil.getPortletById(
        PortalUtil.getCompanyId(req), groupId, portletId);
      String currentDefaultPreferences = portlet.getDefaultPreferences();

      super.processAction(mapping, form, config, req, res);
     
      if( SessionErrors.size(req) == 0 ) {
        String newDefaultPreferences = ParamUtil.getString(
View Full Code Here

  public com.dotcms.repackage.javax.portlet.PortletPreferences getDefaultPreferences(
      String companyId, String portletId)
    throws PortalException, SystemException {

    Portlet portlet = PortletManagerUtil.getPortletById(
      companyId, portletId);

    return PortletPreferencesSerializer.fromDefaultXML(
      portlet.getDefaultPreferences());
  }
View Full Code Here

      (PortletPreferencesImpl)prefsPool.get(pk);

    if (prefs == null) {
      PortletPreferences portletPreferences = null;

      Portlet portlet = null;
//      if (groupId != null) {
//        portlet = PortletManagerUtil.getPortletById(
//          companyId, groupId, pk.portletId);
//      }
//      else {
        portlet = PortletManagerUtil.getPortletById(
          companyId, pk.portletId);
//      }

      try {
        portletPreferences =
          PortletPreferencesUtil.findByPrimaryKey(pk);
      }
      catch (NoSuchPortletPreferencesException nsppe) {
        portletPreferences = PortletPreferencesUtil.create(pk);

        portletPreferences.setPreferences(
          portlet.getDefaultPreferences());

        PortletPreferencesUtil.update(portletPreferences);
      }

      prefs = PortletPreferencesSerializer.fromXML(
View Full Code Here

    if (user != null) {
      try {
        String strutsPath = path.substring(
          1, path.lastIndexOf(StringPool.SLASH));

        Portlet portlet = PortletManagerUtil.getPortletByStrutsPath(
          user.getCompanyId(), strutsPath);

        if (portlet != null && portlet.isActive()) {
//          if (!RoleLocalManagerUtil.hasRoles(
//              user.getUserId(), portlet.getRolesArray())) {
//           
//           
//            throw new PrincipalException();
//          }
        }
        else if (portlet != null && !portlet.isActive()) {
          ForwardConfig forwardConfig =
            mapping.findForward(_PATH_PORTAL_PORTLET_INACTIVE);

          processForwardConfig(req, res, forwardConfig);
View Full Code Here

TOP

Related Classes of com.liferay.portal.model.Portlet

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.