Skip to content

Commit d286dc9

Browse files
committed
fix sonar smells
1 parent 9d14484 commit d286dc9

File tree

7 files changed

+32
-34
lines changed

7 files changed

+32
-34
lines changed

aemdesign-aem-services/src/main/java/design/aem/models/v2/details/EventDetails.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public Map<String, Object> processComponentFields(ComponentProperties componentP
213213

214214
componentProperties.putAll(newFields);
215215

216-
newFields.put("titleFormatted",compileComponentMessage(FIELD_FORMAT_TITLE,DEFAULT_FORMAT_TITLE,componentProperties,sling));
216+
newFields.put(FIELD_FORMATTED_TITLE,compileComponentMessage(FIELD_FORMAT_TITLE,DEFAULT_FORMAT_TITLE,componentProperties,sling));
217217
newFields.put("subTitleFormatted",compileComponentMessage("subTitleFormat",DEFAULT_FORMAT_SUBTITLE,componentProperties,sling));
218218
newFields.put("eventDisplayDateFormatted",compileComponentMessage("eventDisplayDateFormat",DEFAULT_FORMAT_DISPLAYDATE,componentProperties,sling));
219219
newFields.put("eventDisplayTimeFormatted",compileComponentMessage("eventDisplayTimeFormat",DEFAULT_FORMAT_DISPLAYTIME,componentProperties,sling));

aemdesign-aem-services/src/main/java/design/aem/models/v2/layout/Columns.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ protected void ready() {
168168
aColumnClass = MessageFormat.format("{0} {1} {2} {3}",columnClassSmall, columnClassMedium, columnClassLarge, columnClassXLarge).trim();
169169

170170
columnClass = getColumnClass(currentColumn, componentProperties, aColumnClass);
171-
columnsClass = getColumnsClass(numCols, componentProperties);
172-
rowClass = getRowClass(componentProperties, aRowClass);
171+
columnsClass = getColumnsClass(numCols);
172+
rowClass = getRowClass(aRowClass);
173173

174174
componentProperties.attr.add("class", columnsClass);
175175

@@ -274,13 +274,13 @@ final String getColumnClass(Integer colNumber, ComponentProperties componentProp
274274
}
275275
}
276276

277-
final String getColumnsClass(Integer numCols, ComponentProperties componentProperties) {
277+
final String getColumnsClass(Integer numCols) {
278278

279279
return MessageFormat.format("colctrl-{0}c",numCols);
280280

281281
}
282282

283-
final String getRowClass(ComponentProperties componentProperties, String rowClass) {
283+
final String getRowClass(String rowClass) {
284284

285285
return MessageFormat.format("{0} {1} {2}",COLUMNS_CLASS, ROW_CLASS, rowClass);
286286
}

aemdesign-aem-services/src/main/java/design/aem/models/v2/lists/List.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ public ComponentProperties getComponentProperties() {
9999
return this.componentProperties;
100100
}
101101

102-
public final String LISTITEM_LINK_TEXT = "listItemLinkText";
103-
public final String LISTITEM_LINK_TITLE = "listItemLinkTitle";
104-
105-
private final String FIELD_FEED_ENABLED = "feedEnabled";
106-
private final String FIELD_FEED_TYPE = "feedType";
107-
private final String FIELD_FEED_EXT = "feedExt";
108-
private final String FIELD_FEED_TITLE = "feedTitle";
109-
private final String FIELD_FEED_URL = "feedUrl";
102+
public static final String LISTITEM_LINK_TEXT = "listItemLinkText";
103+
public static final String LISTITEM_LINK_TITLE = "listItemLinkTitle";
104+
105+
private static final String FIELD_FEED_ENABLED = "feedEnabled";
106+
private static final String FIELD_FEED_TYPE = "feedType";
107+
private static final String FIELD_FEED_EXT = "feedExt";
108+
private static final String FIELD_FEED_TITLE = "feedTitle";
109+
private static final String FIELD_FEED_URL = "feedUrl";
110110

111111
private java.util.List<Map<String,Object>> listItems;
112112

aemdesign-aem-services/src/main/java/design/aem/utils/components/ComponentDetailsUtil.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public static List<ComponentProperties> getPageListInfo(WCMUsePojo wcmUsePojoMod
4242
return getPageListInfo(wcmUsePojoModel, pageManager, resourceResolver, paths, DEFAULT_LIST_DETAILS_SUFFIX, DEFAULT_LIST_PAGE_CONTENT);
4343

4444
} catch (Exception ex) {
45-
LOGGER.error("getPageListInfo(WCMUsePojo) could not read required objects: {}, error: {}", wcmUsePojoModel, ex);
45+
LOGGER.error("getPageListInfo(WCMUsePojo) /A1 -> A2 could not read required objects: {}, error: {}", wcmUsePojoModel, ex);
4646
}
4747

4848
return new ArrayList<>();
@@ -73,7 +73,7 @@ public static List<ComponentProperties> getPageListInfo(WCMUsePojo wcmUsePojoMod
7373
return getPageListInfo(wcmUsePojoModel, pageManager, resourceResolver, paths, componentNames, pageRoots, null, false);
7474

7575
} catch (Exception ex) {
76-
LOGGER.error("getPageListInfo(WCMUsePojo) could not read required objects: {}, error: {}", wcmUsePojoModel, ex);
76+
LOGGER.error("getPageListInfo(WCMUsePojo) A2 -> A3 could not read required objects: {}, error: {}", wcmUsePojoModel, ex);
7777
}
7878

7979
return new ArrayList<>();
@@ -104,7 +104,7 @@ public static List<ComponentProperties> getPageListInfo(WCMUsePojo wcmUsePojoMod
104104
return getPageListInfo(getContextObjects(wcmUsePojoModel), pageManager, resourceResolver, paths, componentNames, pageRoots, null, false);
105105

106106
} catch (Exception ex) {
107-
LOGGER.error("getPageListInfo(WCMUsePojo) could not read required objects: {},error={},pageManager={},resourceResolver={},pageList={},detailsComponentName={},pageRoots={}",wcmUsePojoModel, ex, pageManager, resourceResolver, paths, componentNames, pageRoots);
107+
LOGGER.error("getPageListInfo(WCMUsePojo) A3 could not read required objects: {},error={},pageManager={},resourceResolver={},pageList={},detailsComponentName={},pageRoots={}",wcmUsePojoModel, ex, pageManager, resourceResolver, paths, componentNames, pageRoots);
108108
}
109109

110110
return new ArrayList<>();
@@ -155,7 +155,7 @@ public static List<ComponentProperties> getPageListInfo(WCMUsePojo wcmUsePojoMod
155155
return getPageListInfo(wcmUsePojoModel, pageManager, resourceResolver, pageList, DEFAULT_LIST_DETAILS_SUFFIX, DEFAULT_LIST_PAGE_CONTENT);
156156

157157
} catch (Exception ex) {
158-
LOGGER.error("getPageListInfo(WCMUsePojo) could not read required objects: {}, error: {}", wcmUsePojoModel, ex);
158+
LOGGER.error("getPageListInfo(WCMUsePojo) B1 -> B2 could not read required objects: {}, error: {}", wcmUsePojoModel, ex);
159159
}
160160

161161
return new ArrayList<>();
@@ -190,7 +190,7 @@ public static List<ComponentProperties> getPageListInfo(WCMUsePojo wcmUsePojoMod
190190
return getPageListInfo(wcmUsePojoModel, pageManager, resourceResolver, pageList, detailsComponentName, pageRoots, null, false);
191191

192192
} catch (Exception ex) {
193-
LOGGER.error("getPageListInfo(WCMUsePojo) could not read required objects: {}, error: {}", wcmUsePojoModel, ex);
193+
LOGGER.error("getPageListInfo(WCMUsePojo) B2 -> B3 could not read required objects: {}, error: {}", wcmUsePojoModel, ex);
194194
}
195195

196196
return new ArrayList<>();
@@ -205,7 +205,7 @@ public static List<ComponentProperties> getPageListInfo(PageContext pageContext,
205205
return getPageListInfo(pageContext, pageManager, resourceResolver, pageList, detailsComponentName, pageRoots, null, false);
206206

207207
} catch (Exception ex) {
208-
LOGGER.error("getPageListInfo(PageContext) could not read required objects", ex);
208+
LOGGER.error("getPageListInfo(PageContext) B2 -> B3 could not read required objects", ex);
209209
}
210210

211211
return new ArrayList<>();
@@ -222,7 +222,7 @@ public static List<ComponentProperties> getPageListInfo(WCMUsePojo wcmUsePojoMod
222222
return getPageListInfo(getContextObjects(wcmUsePojoModel), pageManager, resourceResolver, pageList, detailsComponentName, pageRoots, null, false);
223223

224224
} catch (Exception ex) {
225-
LOGGER.error("getPageListInfo(WCMUsePojo) could not read required objects: {},error={},pageManager={},resourceResolver={},pageList={},detailsComponentName={},pageRoots={}",wcmUsePojoModel, ex, pageManager, resourceResolver, pageList, detailsComponentName, pageRoots);
225+
LOGGER.error("getPageListInfo(WCMUsePojo) B3 could not read required objects: {},error={},pageManager={},resourceResolver={},pageList={},detailsComponentName={},pageRoots={}",wcmUsePojoModel, ex, pageManager, resourceResolver, pageList, detailsComponentName, pageRoots);
226226
}
227227

228228
return new ArrayList<>();
@@ -237,7 +237,7 @@ public static List<ComponentProperties> getPageListInfo(PageContext pageContext,
237237
return getPageListInfo(getContextObjects(pageContext), pageManager, resourceResolver, pageList, detailsComponentName, pageRoots, null, false);
238238

239239
} catch (Exception ex) {
240-
LOGGER.error("getPageListInfo(PageContext) could not read required objects", ex);
240+
LOGGER.error("getPageListInfo(PageContext) B3 could not read required objects", ex);
241241
}
242242

243243
return new ArrayList<>();

aemdesign-aem-services/src/main/java/design/aem/utils/components/ComponentsUtil.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ public static ComponentProperties getComponentProperties(WCMUsePojo wcmUsePojoMo
827827
return getComponentProperties(getContextObjects(wcmUsePojoModel), targetResource, true, fieldLists);
828828

829829
} catch (Exception ex) {
830-
LOGGER.error("getComponentProperties(WCMUsePojo) could not read required objects: {}, error: {}", wcmUsePojoModel, ex);
830+
LOGGER.error("getComponentProperties(wcmUsePojoModel,targetResource,fieldLists) could not read required objects: {}, error: {}", wcmUsePojoModel, ex);
831831
}
832832

833833

@@ -848,7 +848,7 @@ public static ComponentProperties getComponentProperties(GenericModel genericMod
848848
return getComponentProperties(genericModel.getPageContextMap(), targetResource, true, fieldLists);
849849

850850
} catch (Exception ex) {
851-
LOGGER.error("getComponentProperties(WCMUsePojo) could not read required objects: {}, error: {}", genericModel, ex);
851+
LOGGER.error("getComponentProperties(genericModel,targetResource,fieldLists) could not read required objects: {}, error: {}", genericModel, ex);
852852
}
853853

854854

@@ -958,7 +958,7 @@ public static ComponentProperties getComponentProperties(GenericModel genericMod
958958
return getComponentProperties(genericModel.getPageContextMap(), targetResource, includeComponentAttributes, fieldLists);
959959

960960
} catch (Exception ex) {
961-
LOGGER.error("getComponentProperties(WCMUsePojo) could not read required objects: {}, error: {}", genericModel, ex);
961+
LOGGER.error("getComponentProperties(genericModel,targetResource,includeComponentAttributes,fieldLists) could not read required objects: {}, error: {}", genericModel, ex);
962962
}
963963

964964

@@ -979,7 +979,7 @@ public static ComponentProperties getComponentProperties(WCMUsePojo wcmUsePojoMo
979979
return getComponentProperties(getContextObjects(wcmUsePojoModel), targetResource, includeComponentAttributes, fieldLists);
980980

981981
} catch (Exception ex) {
982-
LOGGER.error("getComponentProperties(WCMUsePojo) could not read required objects: {}, error: {}", wcmUsePojoModel, ex);
982+
LOGGER.error("getComponentProperties(wcmUsePojoModel,targetResource,includeComponentAttributes,fieldLists) could not read required objects: {}, error: {}", wcmUsePojoModel, ex);
983983
}
984984

985985

aemdesign-aem-services/src/main/java/design/aem/utils/components/ParagraphUtil.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,9 @@ public static void closeCol(Paragraph par, JspWriter out) throws IOException {
186186
* look ahead try find the end/break of col and return component before it if there is one
187187
* @param parSys list of pars being processed
188188
* @param par current par child of parSys being processed
189-
* @param out html output
190189
* @return last item in the column
191190
*/
192-
public static Paragraph getLastItemInColumn(Object parSys, Paragraph par, JspWriter out) {
191+
public static Paragraph getLastItemInColumn(Object parSys, Paragraph par) {
193192
Paragraph lastItemPar = null;
194193

195194
int parPosition = getListPosition(parSys, par);
@@ -204,10 +203,8 @@ public static Paragraph getLastItemInColumn(Object parSys, Paragraph par, JspWri
204203
if (lpar != null) {
205204
//check if the component is a column, if it is stop
206205
Resource rpar = lpar.getResource();
207-
if (rpar != null) {
208-
if (rpar.getResourceType().endsWith("/colctrl")) {
209-
break;
210-
}
206+
if (rpar != null && rpar.getResourceType().endsWith("/colctrl")) {
207+
break;
211208
}
212209
}
213210
}
@@ -445,7 +442,7 @@ public static Resource getFirstElement(final Iterator<Resource> itr) {
445442
* @param currColNumber current column number
446443
* @throws IOException when can't write to jsp output
447444
*/
448-
public static void openCol(JspWriter out, HashMap<String, Object> componentStyle, Integer currColNumber) throws IOException {
445+
public static void openCol(JspWriter out, Map componentStyle, Integer currColNumber) throws IOException {
449446
String layout = (String) componentStyle.get(COL_CTL_LAYOUT);
450447

451448
//expected width format: col-md-,4,4,4

aemdesign-aem-services/src/main/java/design/aem/utils/components/SlingPostUtil.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import javax.jcr.Node;
1414
import javax.jcr.PropertyType;
15+
import javax.jcr.RepositoryException;
1516
import javax.servlet.http.HttpServletRequest;
1617
import java.util.ArrayList;
1718
import java.util.Enumeration;
@@ -47,9 +48,9 @@ public static void processDeletes(final Node parentNode, final HttpServletReques
4748
* Copied from Sling. Later on Sling POST Servlet will be refactored to provide a generic service for this.
4849
* @param parentNode node to write into
4950
* @param req sling request
50-
* @throws Exception when can't read content
51+
* @throws RepositoryException when can't read content
5152
*/
52-
public static void writeContent(final Node parentNode, final HttpServletRequest req) throws Exception {
53+
public static void writeContent(final Node parentNode, final HttpServletRequest req) throws RepositoryException {
5354
for (Enumeration en = req.getParameterNames(); en.hasMoreElements();) {
5455
String name = en.nextElement().toString();
5556

0 commit comments

Comments
 (0)