Skip to content

Commit

Permalink
LPS-82433 Hack for ServiceBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
brianchandotcom committed Jun 20, 2018
1 parent a2a4e19 commit 2a0a837
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
Expand Up @@ -91,17 +91,18 @@ public static boolean hasEntityColumn(
return false;
}

public Entity(String name) {
public Entity(ServiceBuilder serviceBuilder, String name) {
this(
null, null, null, name, null, null, null, false, false, false,
false, true, null, null, null, null, null, true, false, false,
false, false, null, false, null, null, false, null, null, null,
null, null, null, null, null, null, null, false);
serviceBuilder, null, null, null, name, null, null, null, false,
false, false, false, true, null, null, null, null, null, true,
false, false, false, false, null, false, null, null, false, null,
null, null, null, null, null, null, null, null, null, false);
}

public Entity(
String packagePath, String apiPackagePath, String portletShortName,
String name, String humanName, String table, String alias, boolean uuid,
ServiceBuilder serviceBuilder, String packagePath,
String apiPackagePath, String portletShortName, String name,
String humanName, String table, String alias, boolean uuid,
boolean uuidAccessor, boolean externalReferenceCode,
boolean localService, boolean remoteService, String persistenceClass,
String finderClassName, String dataSource, String sessionFactory,
Expand All @@ -118,6 +119,7 @@ public Entity(
List<String> unresolvedReferenceEntityNames,
List<String> txRequiredMethodNames, boolean resourceActionModel) {

_serviceBuilder = serviceBuilder;
_packagePath = packagePath;
_apiPackagePath = apiPackagePath;
_portletShortName = portletShortName;
Expand Down Expand Up @@ -1021,11 +1023,26 @@ public boolean isPermissionCheckEnabled() {
}

public boolean isPermissionCheckEnabled(EntityFinder entityFinder) {
boolean resourceActionModel = _resourceActionModel;

if (_serviceBuilder.isVersionLTE_7_1_0()) {

// See LPS-82433. Add this hack to prevent
// 4d29a89578e0a712ddcb6793d93c8fc9128c3b03 in 7.1.x from requring
// a major breaking change in portal-kernel.

if (_packagePath.equals("com.liferay.portlet.asset") &&
_name.equals("AssetTag")) {

resourceActionModel = true;
}
}

String entityFinderName = entityFinder.getName();

if (_name.equals("Group") || _name.equals("User") ||
entityFinderName.equals("UUID_G") || !entityFinder.isCollection() ||
!hasPrimitivePK() || !_resourceActionModel) {
!hasPrimitivePK() || !resourceActionModel) {

return false;
}
Expand Down Expand Up @@ -1252,6 +1269,7 @@ private EntityColumn _getPKEntityColumn() {
private final List<EntityColumn> _regularEntityColumns;
private final boolean _remoteService;
private final boolean _resourceActionModel;
private ServiceBuilder _serviceBuilder;
private final String _sessionFactory;
private final String _table;
private List<String> _transients;
Expand Down
Expand Up @@ -1035,7 +1035,7 @@ public Entity getEntity(String name) throws Exception {
int pos = name.lastIndexOf(".");

if (pos == -1) {
pos = _entities.indexOf(new Entity(name));
pos = _entities.indexOf(new Entity(this, name));

if (pos == -1) {
throw new ServiceBuilderException(
Expand All @@ -1055,7 +1055,7 @@ public Entity getEntity(String name) throws Exception {
String refEntity = name.substring(pos + 1);

if (refPackage.equals(_packagePath)) {
pos = _entities.indexOf(new Entity(refEntity));
pos = _entities.indexOf(new Entity(this, refEntity));

if (pos == -1) {
throw new ServiceBuilderException(
Expand Down Expand Up @@ -1862,8 +1862,18 @@ public boolean isTxRequiredMethod(
}

public boolean isVersionGTE_7_1_0() {
if (_dtdVersion.isSameVersionAs("7.1.0") ||
_dtdVersion.isLaterVersionThan("7.1.0")) {
if (_dtdVersion.isLaterVersionThan("7.1.0") ||
_dtdVersion.isSameVersionAs("7.1.0")) {

return true;
}

return false;
}

public boolean isVersionLTE_7_1_0() {
if (_dtdVersion.isPreviousVersionThan("7.1.0") ||
_dtdVersion.isSameVersionAs("7.1.0")) {

return true;
}
Expand Down Expand Up @@ -6088,7 +6098,7 @@ else if (orderColBy.equals("desc")) {
_apiPackagePath + ".model." + entityName);

Entity entity = new Entity(
_packagePath, _apiPackagePath, _portletShortName, entityName,
this, _packagePath, _apiPackagePath, _portletShortName, entityName,
humanName, tableName, alias, uuid, uuidAccessor,
externalReferenceCode, localService, remoteService,
persistenceClassName, finderClassName, dataSource, sessionFactory,
Expand Down

0 comments on commit 2a0a837

Please sign in to comment.