Skip to content

Commit

Permalink
LPS-57489 Update ResourceActionsImpl with the new attribute handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Máté Thurzó authored and brianchandotcom committed Jul 30, 2015
1 parent 6b5abae commit 209766d
Showing 1 changed file with 19 additions and 34 deletions.
Expand Up @@ -21,6 +21,7 @@
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.security.pacl.DoPrivileged;
import com.liferay.portal.kernel.util.ArrayUtil;
import com.liferay.portal.kernel.util.CharPool;
import com.liferay.portal.kernel.util.ContentTypes;
import com.liferay.portal.kernel.util.GetterUtil;
Expand All @@ -34,25 +35,19 @@
import com.liferay.portal.kernel.xml.Element;
import com.liferay.portal.kernel.xml.UnsecureSAXReaderUtil;
import com.liferay.portal.model.Group;
import com.liferay.portal.model.LayoutPrototype;
import com.liferay.portal.model.LayoutSetPrototype;
import com.liferay.portal.model.Organization;
import com.liferay.portal.model.PasswordPolicy;
import com.liferay.portal.model.Portlet;
import com.liferay.portal.model.PortletConstants;
import com.liferay.portal.model.ResourceAction;
import com.liferay.portal.model.Role;
import com.liferay.portal.model.RoleConstants;
import com.liferay.portal.model.User;
import com.liferay.portal.model.UserGroup;
import com.liferay.portal.service.GroupServiceUtil;
import com.liferay.portal.service.PortletLocalService;
import com.liferay.portal.service.ResourceActionLocalService;
import com.liferay.portal.service.RoleLocalService;
import com.liferay.portal.util.PortletKeys;
import com.liferay.portal.util.PropsValues;
import com.liferay.portlet.expando.model.ExpandoColumn;
import com.liferay.portlet.mobiledevicerules.model.MDRRuleGroup;
import com.liferay.registry.collections.ServiceTrackerCollections;
import com.liferay.registry.collections.ServiceTrackerMap;
import com.liferay.util.JS;
Expand Down Expand Up @@ -91,18 +86,6 @@ public ResourceActionsImpl() {
}

public void afterPropertiesSet() {
_organizationModelResources = new HashSet<>();

for (String resource : getOrganizationModelResources()) {
_organizationModelResources.add(resource);
}

_portalModelResources = new HashSet<>();

for (String resource : getPortalModelResources()) {
_portalModelResources.add(resource);
}

_portletResourceActionsBags = new HashMap<>();
_modelResourceActionsBags = new HashMap<>();

Expand Down Expand Up @@ -330,12 +313,12 @@ public Double getModelResourceWeight(String name) {

@Override
public String[] getOrganizationModelResources() {
return _ORGANIZATION_MODEL_RESOURCES;
return ArrayUtil.toStringArray(_organizationModelResources);
}

@Override
public String[] getPortalModelResources() {
return _PORTAL_MODEL_RESOURCES;
return ArrayUtil.toStringArray(_portalModelResources);
}

@Override
Expand Down Expand Up @@ -1041,6 +1024,20 @@ protected void readModelResource(

String name = modelResourceElement.elementTextTrim("model-name");

boolean organizationModelResource = GetterUtil.getBoolean(
modelResourceElement.attributeValue("organization"));

if (organizationModelResource) {
_organizationModelResources.add(name);
}

boolean portalModelResource = GetterUtil.getBoolean(
modelResourceElement.attributeValue("portal"));

if (portalModelResource) {
_portalModelResources.add(name);
}

ModelResourceActionsBag modelResourceActionsBag =
getModelResourceActionsBag(name);

Expand Down Expand Up @@ -1230,24 +1227,12 @@ protected Set<String> readSupportsActions(

private static final String _MODEL_RESOURCE_NAME_PREFIX = "model.resource.";

private static final String[] _ORGANIZATION_MODEL_RESOURCES = {
Organization.class.getName(), PasswordPolicy.class.getName(),
User.class.getName()
};

private static final String[] _PORTAL_MODEL_RESOURCES = {
ExpandoColumn.class.getName(), LayoutPrototype.class.getName(),
LayoutSetPrototype.class.getName(), MDRRuleGroup.class.getName(),
Organization.class.getName(), PasswordPolicy.class.getName(),
Role.class.getName(), User.class.getName(), UserGroup.class.getName()
};

private static final Log _log = LogFactoryUtil.getLog(
ResourceActionsImpl.class);

private Map<String, ModelResourceActionsBag> _modelResourceActionsBags;
private Set<String> _organizationModelResources;
private Set<String> _portalModelResources;
private final Set<String> _organizationModelResources = new HashSet<>();
private final Set<String> _portalModelResources = new HashSet<>();
private Map<String, PortletResourceActionsBag> _portletResourceActionsBags;
private final ServiceTrackerMap<String, List<ResourceBundle>>
_resourceBundles;
Expand Down

0 comments on commit 209766d

Please sign in to comment.