Skip to content

Commit

Permalink
MGR-97 remove coed smells
Browse files Browse the repository at this point in the history
  • Loading branch information
madness-inc committed Feb 4, 2020
1 parent 54239af commit 1c4c27e
Show file tree
Hide file tree
Showing 20 changed files with 70 additions and 91 deletions.
Expand Up @@ -65,7 +65,7 @@ public DataContainer getData(Site site, Application application, org.appng.api.E

LocalNodeState localNode = getLocalNode(site, environment);
LocalNodeState currentNode = localNode;
Set<LocalNodeState> items = new HashSet<LocalNodeState>();
Set<LocalNodeState> items = new HashSet<>();
items.add(localNode);

boolean clusterAvailable = null != nodeStates;
Expand Down
Expand Up @@ -53,7 +53,7 @@ public class Dictionary extends ServiceAware implements DataProvider {
public DataContainer getData(Site site, Application application, Environment environment, Options options,
Request request, FieldProcessor fp) {
ResourceBundle bundle = null;
List<Property> properties = new ArrayList<Property>();
List<Property> properties = new ArrayList<>();

Integer applicationId = options.getInteger("application", "id");
Locale locale = environment.getLocale();
Expand Down
Expand Up @@ -31,7 +31,6 @@
import org.appng.application.manager.MessageConstants;
import org.appng.application.manager.service.Service;
import org.appng.application.manager.service.ServiceAware;
import org.appng.core.model.InstallablePackage;
import org.appng.xml.platform.Selection;
import org.appng.xml.platform.SelectionGroup;
import org.appng.xml.platform.SelectionType;
Expand Down Expand Up @@ -106,7 +105,7 @@ public DataContainer getData(Site site, Application application, Environment env
data = service.searchPackageVersions(request, fp, repositoryId, applicationName);
}
} catch (BusinessException ex) {
data.setPage(new ArrayList<InstallablePackage>(), fp.getPageable());
data.setPage(new ArrayList<>(), fp.getPageable());
}
return data;
}
Expand Down
Expand Up @@ -54,11 +54,7 @@ public DataContainer getData(Site site, Application application, Environment env
jars = new ArrayList<JarInfo>();
File baseFolder = new File(System.getProperty("catalina.base"), "lib");
File homeFolder = new File(System.getProperty("catalina.home"), "lib");
FilenameFilter jarFilter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".jar");
}
};
FilenameFilter jarFilter = (dir, name) -> name.endsWith(".jar");
for (String jarfile : baseFolder.list(jarFilter)) {
jars.add(JarInfoBuilder.getJarInfo(new File(baseFolder, jarfile)));
}
Expand Down
Expand Up @@ -159,13 +159,15 @@ public class PropertyWrapper extends PropertyImpl {
this.hidePassword = hidePassword;
}

@Override
public String getActualString() {
if (hidePassword && Property.Type.PASSWORD.equals(getType())) {
return property.getActualString().replaceAll("\\.", "*");
}
return property.getActualString();
}

@Override
public Boolean getChangedValue() {
return property.getChangedValue();
}
Expand All @@ -174,10 +176,12 @@ public String getShortName() {
return getName().substring(getName().lastIndexOf('.') + 1);
}

@Override
public String getString() {
return property.getString();
}

@Override
public Boolean getBoolean() {
return property.getBoolean();
}
Expand All @@ -186,6 +190,7 @@ public void setBoolean(Boolean value) {
property.setActualString(value.toString());
}

@Override
public Integer getInteger() {
return property.getInteger();
}
Expand All @@ -194,46 +199,57 @@ public void setInteger(Integer value) {
property.setActualString(value.toString());
}

@Override
public Float getFloat() {
return property.getFloat();
}

@Override
public Double getDouble() {
return property.getDouble();
}

@Override
public byte[] getBlob() {
return property.getBlob();
}

@Override
public String getClob() {
return property.getClob();
}

@Override
public String getName() {
return property.getName();
}

@Override
public boolean isMandatory() {
return property.isMandatory();
}

@Override
public String getDefaultString() {
return property.getDefaultString();
}

@Override
public Type getType() {
return property.getType();
}

@Override
public Object getValue() {
return property.getValue();
}

@Override
public void setValue(Object value) {
property.setValue(value);
}

@Override
public String getDescription() {
return property.getDescription();
}
Expand Down
Expand Up @@ -162,7 +162,7 @@ protected List<Session> getSessions(Options options, Request request, Boolean cu
final String fAgnt, String fUsr, final Date fcrBfDate, final Date fcrAfDate, final String fLgn) {
Integer siteId = options.getInteger("site", "id");
String currentSiteName = null == siteId ? null : getService().getNameForSite(siteId);
List<Session> sessions = new ArrayList<Session>();
List<Session> sessions = new ArrayList<>();
for (Session session : imutableSessions) {
String userAgent = session.getUserAgent();
if (StringUtils.isBlank(userAgent)) {
Expand Down
Expand Up @@ -182,7 +182,7 @@ public void setHasError(boolean hasError) {
}

public List<String> getQueries(String sql, DatabaseConnection connection) {
List<String> queries = new ArrayList<String>();
List<String> queries = new ArrayList<>();
try (Database<?> db = DatabaseFactory
.createDatabase(new FluentConfiguration().dataSource(connection.getDataSource()), true)) {
SqlScript sqlScript = new SqlScript(db.createSqlStatementBuilderFactory(), new StringResource(sql), false);
Expand Down
Expand Up @@ -86,8 +86,9 @@ public String next() {
return sb.toString();
}

@Override
public void remove() {

// not needed
}
}

Expand Down
Expand Up @@ -19,7 +19,6 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
Expand Down Expand Up @@ -123,8 +122,7 @@ public byte[] processRequest(Site site, Application application, Environment env
return new byte[0];
}

private void addFile(ArchiveOutputStream os, File srcFile, String currentFolder)
throws FileNotFoundException, IOException {
private void addFile(ArchiveOutputStream os, File srcFile, String currentFolder) throws IOException {
if (null != srcFile && srcFile.exists()) {
for (File file : srcFile.listFiles()) {
String path = currentFolder + "/" + file.getName();
Expand All @@ -145,12 +143,11 @@ private void addProperties(ArchiveOutputStream os, String name, Map<?, ?> map) t
addArchiveEntry(os, name, new ByteArrayInputStream(propsOut.toByteArray()), null);
}

private void addArchiveEntry(ArchiveOutputStream os, File file) throws FileNotFoundException, IOException {
private void addArchiveEntry(ArchiveOutputStream os, File file) throws IOException {
addArchiveEntry(os, file.getName(), file);
}

private void addArchiveEntry(ArchiveOutputStream os, String name, File file)
throws FileNotFoundException, IOException {
private void addArchiveEntry(ArchiveOutputStream os, String name, File file) throws IOException {
if (file.exists()) {
addArchiveEntry(os, name, new FileInputStream(file), file.lastModified());
}
Expand Down
Expand Up @@ -28,7 +28,7 @@ public class GrantForm {
private boolean showGrantedBy = false;

public GrantForm() {
this.grantedSiteIds = new HashSet<Integer>();
this.grantedSiteIds = new HashSet<>();
}

public GrantForm(SiteApplication siteApplication) {
Expand Down
Expand Up @@ -37,7 +37,7 @@ public class GroupForm {

private GroupImpl group;

private List<Integer> roleIds = new ArrayList<Integer>();
private List<Integer> roleIds = new ArrayList<>();

public GroupForm() {
this(new GroupImpl());
Expand Down
Expand Up @@ -15,7 +15,7 @@
*/
package org.appng.application.manager.form;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

import org.appng.api.model.Resource;
import org.appng.api.model.ResourceType;
Expand All @@ -28,20 +28,14 @@
*/
public class ResourceForm {

public static final String ENCODING = "UTF-8";

private Integer id;
private String name;
private ResourceType type;
private String content;

public ResourceForm(Resource resource) {
if (!ResourceType.JAR.equals(resource.getResourceType())) {
try {
this.content = new String(resource.getBytes(), ENCODING);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
this.content = new String(resource.getBytes(), StandardCharsets.UTF_8);
}
this.id = resource.getId();
this.name = resource.getName();
Expand Down
Expand Up @@ -36,9 +36,9 @@
public class RoleForm {

private RoleImpl role;
private List<Integer> permissionIds = new ArrayList<Integer>();
private List<Integer> groupIds = new ArrayList<Integer>();
private List<Integer> userIds = new ArrayList<Integer>();
private List<Integer> permissionIds = new ArrayList<>();
private List<Integer> groupIds = new ArrayList<>();
private List<Integer> userIds = new ArrayList<>();

public RoleForm() {
this(new RoleImpl());
Expand Down
Expand Up @@ -25,6 +25,7 @@
import org.appng.application.manager.business.PlatformEvents.EventFilter;
import org.appng.application.manager.service.PlatformEventService;
import org.appng.application.manager.service.RoleService;
import org.appng.core.domain.SubjectImpl;
import org.appng.core.service.DatabaseService;
import org.appng.mail.Mail;
import org.appng.mail.Mail.RecipientType;
Expand All @@ -50,7 +51,7 @@ public void execute(Site site, Application application) throws Exception {
Properties properties = application.getProperties();
List<String> receivers = properties.getList(ManagerSettings.DATABASE_REPORT_RECEIVERS, ";");

Collection<? extends org.appng.api.model.Subject> reportReceivers = roleService.getSubjectsForRole(application,
Collection<SubjectImpl> reportReceivers = roleService.getSubjectsForRole(application,
ROLE_DATABASE_REPORT_RECEIVER);

if (!(receivers.isEmpty() && reportReceivers.isEmpty())) {
Expand Down
Expand Up @@ -27,6 +27,7 @@
import org.appng.application.manager.business.PlatformEvents.EventFilter;
import org.appng.application.manager.service.PlatformEventService;
import org.appng.application.manager.service.RoleService;
import org.appng.core.domain.SubjectImpl;
import org.appng.mail.Mail;
import org.appng.mail.Mail.RecipientType;
import org.appng.mail.MailTransport;
Expand All @@ -51,7 +52,7 @@ public void execute(Site site, Application application) throws Exception {
Properties properties = application.getProperties();
List<String> receivers = properties.getList(ManagerSettings.EVENT_REPORT_RECEIVERS, ";");

Collection<? extends org.appng.api.model.Subject> reportReceivers = roleService.getSubjectsForRole(application,
Collection<SubjectImpl> reportReceivers = roleService.getSubjectsForRole(application,
ROLE_EVENT_REPORT_RECEIVER);

if (!(receivers.isEmpty() && reportReceivers.isEmpty())) {
Expand Down

0 comments on commit 1c4c27e

Please sign in to comment.