Skip to content

Commit 99a3966

Browse files
committed
BroadleafCommerce#1512 - Fix formatting issues identified in code review. Note one of the "indentation" issues is due to the fact that the method is in a Proxy instance if you look at the full source.
1 parent b844067 commit 99a3966

File tree

3 files changed

+54
-50
lines changed

3 files changed

+54
-50
lines changed

admin/broadleaf-open-admin-platform/src/main/java/org/broadleafcommerce/openadmin/web/rulebuilder/dto/FieldData.java

+14-12
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* limitations under the License.
1818
* #L%
1919
*/
20+
2021
package org.broadleafcommerce.openadmin.web.rulebuilder.dto;
2122

2223
import org.broadleafcommerce.common.presentation.client.SupportedFieldType;
@@ -51,6 +52,7 @@ private FieldData(Builder builder) {
5152
}
5253

5354
public static class Builder {
55+
5456
protected String fieldLabel = null;
5557
protected String fieldName = null;
5658
protected String operators = null;
@@ -63,7 +65,8 @@ public FieldData build() {
6365
return new FieldData(this);
6466
}
6567

66-
public Builder() {}
68+
public Builder() {
69+
}
6770

6871
public Builder label(String fieldLabel) {
6972
this.fieldLabel = fieldLabel;
@@ -94,10 +97,10 @@ public Builder secondaryType(SupportedFieldType fieldType) {
9497
this.secondaryFieldType = fieldType;
9598
return this;
9699
}
97-
100+
98101
public Builder skipValidation(boolean skipValidation) {
99-
this.skipValidation = skipValidation;
100-
return this;
102+
this.skipValidation = skipValidation;
103+
return this;
101104
}
102105
}
103106

@@ -125,13 +128,12 @@ public SupportedFieldType getSecondaryFieldType() {
125128
return secondaryFieldType;
126129
}
127130

128-
public boolean getSkipValidation() {
129-
return skipValidation;
130-
}
131+
public boolean getSkipValidation() {
132+
return skipValidation;
133+
}
134+
135+
public void setSkipValidation(boolean skipValidation) {
136+
this.skipValidation = skipValidation;
137+
}
131138

132-
public void setSkipValidation(boolean skipValidation) {
133-
this.skipValidation = skipValidation;
134-
}
135-
136-
137139
}

admin/broadleaf-open-admin-platform/src/main/java/org/broadleafcommerce/openadmin/web/rulebuilder/service/AbstractRuleBuilderFieldService.java

+26-24
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
* limitations under the License.
1818
* #L%
1919
*/
20+
2021
package org.broadleafcommerce.openadmin.web.rulebuilder.service;
2122

2223
import org.apache.commons.lang.ArrayUtils;
@@ -77,14 +78,14 @@ public FieldWrapper buildFields() {
7778
for (FieldData field : getFields()) {
7879
FieldDTO fieldDTO = new FieldDTO();
7980
fieldDTO.setLabel(field.getFieldLabel());
80-
81+
8182
//translate the label to display
8283
String label = field.getFieldLabel();
8384
BroadleafRequestContext context = BroadleafRequestContext.getBroadleafRequestContext();
8485
MessageSource messages = context.getMessageSource();
8586
label = messages.getMessage(label, null, label, context.getJavaLocale());
8687
fieldDTO.setLabel(label);
87-
88+
8889
fieldDTO.setName(field.getFieldName());
8990
fieldDTO.setOperators(field.getOperators());
9091
fieldDTO.setOptions(field.getOptions());
@@ -99,7 +100,7 @@ public SupportedFieldType getSupportedFieldType(String fieldName) {
99100
SupportedFieldType type = null;
100101
if (fieldName != null) {
101102
for (FieldData field : getFields()) {
102-
if (fieldName.equals(field.getFieldName())){
103+
if (fieldName.equals(field.getFieldName())) {
103104
return field.getFieldType();
104105
}
105106
}
@@ -112,7 +113,7 @@ public SupportedFieldType getSecondaryFieldType(String fieldName) {
112113
SupportedFieldType type = null;
113114
if (fieldName != null) {
114115
for (FieldData field : getFields()) {
115-
if (fieldName.equals(field.getFieldName())){
116+
if (fieldName.equals(field.getFieldName())) {
116117
return field.getSecondaryFieldType();
117118
}
118119
}
@@ -155,7 +156,8 @@ public List<FieldData> getFields() {
155156
@Override
156157
@SuppressWarnings("unchecked")
157158
public void setFields(final List<FieldData> fields) {
158-
List<FieldData> proxyFields = (List<FieldData>) Proxy.newProxyInstance(getClass().getClassLoader(), new Class<?>[]{List.class}, new InvocationHandler() {
159+
List<FieldData> proxyFields = (List<FieldData>) Proxy.newProxyInstance(getClass().getClassLoader(), new Class<?>[] { List.class }, new InvocationHandler() {
160+
159161
@Override
160162
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
161163
if (method.getName().equals("add")) {
@@ -174,24 +176,24 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
174176
}
175177

176178
private void testFieldName(FieldData fieldData) throws ClassNotFoundException {
177-
if (! fieldData.getSkipValidation()) {
178-
if (!StringUtils.isEmpty(fieldData.getFieldName()) && dynamicEntityDao != null) {
179-
Class<?>[] dtos = dynamicEntityDao.getAllPolymorphicEntitiesFromCeiling(Class.forName(getDtoClassName()));
180-
if (ArrayUtils.isEmpty(dtos)) {
181-
dtos = new Class<?>[]{Class.forName(getDtoClassName())};
182-
}
183-
Field field = null;
184-
for (Class<?> dto : dtos) {
185-
field = dynamicEntityDao.getFieldManager().getField(dto, fieldData.getFieldName());
186-
if (field != null) {
187-
break;
188-
}
189-
}
190-
if (field == null) {
191-
throw new IllegalArgumentException("Unable to find the field declared in FieldData (" + fieldData.getFieldName() + ") on the target class (" + getDtoClassName() + "), or any registered entity class that derives from it.");
192-
}
193-
}
194-
}
179+
if (!fieldData.getSkipValidation()) {
180+
if (!StringUtils.isEmpty(fieldData.getFieldName()) && dynamicEntityDao != null) {
181+
Class<?>[] dtos = dynamicEntityDao.getAllPolymorphicEntitiesFromCeiling(Class.forName(getDtoClassName()));
182+
if (ArrayUtils.isEmpty(dtos)) {
183+
dtos = new Class<?>[] { Class.forName(getDtoClassName()) };
184+
}
185+
Field field = null;
186+
for (Class<?> dto : dtos) {
187+
field = dynamicEntityDao.getFieldManager().getField(dto, fieldData.getFieldName());
188+
if (field != null) {
189+
break;
190+
}
191+
}
192+
if (field == null) {
193+
throw new IllegalArgumentException("Unable to find the field declared in FieldData (" + fieldData.getFieldName() + ") on the target class (" + getDtoClassName() + "), or any registered entity class that derives from it.");
194+
}
195+
}
196+
}
195197
}
196198
});
197199
this.fields = proxyFields;
@@ -223,7 +225,7 @@ public void afterPropertiesSet() throws Exception {
223225
PersistenceManager persistenceManager = PersistenceManagerFactory.getPersistenceManager(TargetModeType.SANDBOX);
224226
dynamicEntityDao = persistenceManager.getDynamicEntityDao();
225227
setFields(new ArrayList<FieldData>());
226-
228+
227229
// This cannot be null during startup as we do not want to remove the null safety checks in a multi-tenant env.
228230
boolean contextWasNull = false;
229231
if (BroadleafRequestContext.getBroadleafRequestContext() == null) {

common/src/main/java/org/broadleafcommerce/common/RequestDTOImpl.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@
1717
* limitations under the License.
1818
* #L%
1919
*/
20-
package org.broadleafcommerce.common;
21-
22-
import java.io.Serializable;
23-
import java.util.Map;
2420

25-
import javax.servlet.http.HttpServletRequest;
21+
package org.broadleafcommerce.common;
2622

2723
import org.apache.commons.lang3.StringUtils;
2824
import org.broadleafcommerce.common.presentation.AdminPresentation;
2925
import org.broadleafcommerce.common.web.BroadleafRequestContext;
3026
import org.springframework.web.context.request.WebRequest;
3127

28+
import java.io.Serializable;
29+
import java.util.Map;
30+
31+
import javax.servlet.http.HttpServletRequest;
32+
3233
/**
3334
* Created by bpolster.
3435
*/
@@ -39,12 +40,11 @@ public class RequestDTOImpl implements RequestDTO, Serializable {
3940
@AdminPresentation(friendlyName = "RequestDTOImpl_Request_URI")
4041
private String requestURI;
4142

42-
4343
@AdminPresentation(friendlyName = "RequestDTOImpl_Full_Url")
4444
private String fullUrlWithQueryString;
4545

4646
@AdminPresentation(friendlyName = "RequestDTOImpl_Is_Secure")
47-
private Boolean secure;
47+
private Boolean secure;
4848

4949
public RequestDTOImpl(HttpServletRequest request) {
5050
requestURI = request.getRequestURI();
@@ -103,13 +103,13 @@ public void setSecure(Boolean secure) {
103103
public void setRequestURI(String requestURI) {
104104
this.requestURI = requestURI;
105105
}
106-
107-
public Map<String,Object> getProperties() {
108-
if (BroadleafRequestContext.getBroadleafRequestContext() != null) {
109-
return BroadleafRequestContext.getBroadleafRequestContext().getAdditionalProperties();
110-
} else {
111-
return null;
112-
}
106+
107+
public Map<String, Object> getProperties() {
108+
if (BroadleafRequestContext.getBroadleafRequestContext() != null) {
109+
return BroadleafRequestContext.getBroadleafRequestContext().getAdditionalProperties();
110+
} else {
111+
return null;
112+
}
113113
}
114114

115115
}

0 commit comments

Comments
 (0)