Skip to content

Commit

Permalink
Removed anonymous classes
Browse files Browse the repository at this point in the history
  • Loading branch information
car031 committed May 22, 2023
1 parent 2fcd6c1 commit 46293f1
Show file tree
Hide file tree
Showing 163 changed files with 1,692 additions and 2,871 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,8 @@ public void setContentStream(String repositoryId, Holder<String> objectId, Boole
public ObjectList getContentChanges(String repositoryId, Holder<String> changeLogToken, Boolean includeProperties,
String filter, Boolean includePolicyIds, Boolean includeAcl, BigInteger maxItems,
ExtensionsData extension) {
log.debug("getContentChanges " + changeLogToken.getValue() + "|" + filter + " | "
+ new Date(Long.parseLong(changeLogToken.getValue())));
log.debug("getContentChanges {} | {} | {}", changeLogToken.getValue(), filter,
new Date(Long.parseLong(changeLogToken.getValue())));

validateSession();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public CmisService getService(CallContext context) {
if (session != null) {
if (context.getRepositoryId() != null)
session.getDictionary().put(KEY_REPO_ID, context.getRepositoryId());
log.debug("Using session " + session.getSid() + " for user " + session.getUsername());
log.debug("Using session {} for user {}", session.getSid(), session.getUsername());
wrapperService = new ConformanceCmisServiceWrapper(new LDCmisService(context, session.getSid()),
DEFAULT_MAX_ITEMS_TYPES,
BigInteger.valueOf(Context.get().getProperties().getInt("cmis.maxitems", 200)),
Expand Down
22 changes: 9 additions & 13 deletions logicaldoc-cmis/src/main/java/com/logicaldoc/cmis/TypeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private static PropertyDefinition<?> createPropDef(String id, String displayName
result = new PropertyUriDefinitionImpl();
break;
default:
throw new RuntimeException("Unknown datatype! Spec change?");
throw new IllegalArgumentException("Unknown datatype! Spec change?");
}

result.setId(id);
Expand All @@ -417,13 +417,11 @@ private static PropertyDefinition<?> createPropDef(String id, String displayName
* @return if the type has been added
*/
public boolean addType(TypeDefinition type) {
if (type == null) {
if (type == null)
return false;
}

if (type.getBaseTypeId() == null) {
if (type.getBaseTypeId() == null)
return false;
}

// find base type
TypeDefinition baseType = null;
Expand All @@ -450,7 +448,7 @@ public boolean addType(TypeDefinition type) {
// add it
addTypeInteral(newType);

log.info("Added type '" + newType.getId() + "'.");
log.info("Added type '{}'", newType.getId());

return true;
}
Expand Down Expand Up @@ -584,13 +582,11 @@ private TypeDefinitionContainer getTypesDescendants(int depth, TypeDefinitionCon

result.setTypeDefinition(type);

if (depth != 0) {
if (tc.getChildren() != null) {
result.setChildren(new ArrayList<TypeDefinitionContainer>());
for (TypeDefinitionContainer tdc : tc.getChildren()) {
result.getChildren()
.add(getTypesDescendants(depth < 0 ? -1 : depth - 1, tdc, includePropertyDefinitions));
}
if (depth != 0 && tc.getChildren() != null) {
result.setChildren(new ArrayList<TypeDefinitionContainer>());
for (TypeDefinitionContainer tdc : tc.getChildren()) {
result.getChildren()
.add(getTypesDescendants(depth < 0 ? -1 : depth - 1, tdc, includePropertyDefinitions));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected HibernatePersistentObjectDAO(Class<T> entityClass) {
}

public void delete(long id, int code) throws PersistenceException {
if(code==0)
if (code == 0)
throw new IllegalArgumentException("code cannot be 0");

if (!checkStoringAspect())
Expand Down Expand Up @@ -137,10 +137,7 @@ public T findById(long id) throws PersistenceException {
return null;
return entity;
} catch (Throwable e) {
if (e instanceof PersistenceException)
throw (PersistenceException) e;
else
throw new PersistenceException(e);
throw new PersistenceException(e);
}
}

Expand Down Expand Up @@ -500,8 +497,8 @@ protected Query prepareQueryForUpdate(String expression, Map<String, Object> val
private void applyParamsAndLimit(Map<String, Object> values, Integer max, @SuppressWarnings("rawtypes")
Query queryObject) {
if (values != null)
for (String name : values.keySet())
queryObject.setParameter(name, values.get(name));
for (Map.Entry<String, Object> entry : values.entrySet())
queryObject.setParameter(entry.getKey(), entry.getValue());

if (max != null && max > 0)
queryObject.setMaxResults(max);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public void setFileVersion(String fileVersion) {

private String color;

public History() {
protected History() {
}

public String getVersion() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public enum RunLevel {
this.level = level;
}


@Override
public String toString() {
return this.level;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ public static SystemInfo get(long tenantId) {
@SuppressWarnings("unchecked")
Object tmp = clazz.getDeclaredConstructor().newInstance();
if (!(tmp instanceof SystemInfo))
throw new Exception("The specified info " + className + " doesn't implement SystemInfo interface");
throw new ClassNotFoundException(
"The specified info " + className + " doesn't implement SystemInfo interface");

info = (SystemInfo) tmp;
info.setTenantId(tenantId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,12 @@ public void newEvent(History history) {
history.setDocument(clone);
}

Runnable notifier = new Runnable() {
@Override
public void run() {
Runnable notifier = () -> {
log.debug("Notify history {}", history);
for (EventListener listener : listeners) {
listener.newEvent(history);
}
log.debug("Finished notification of history {}", history);
}
};

ThreadPools pools = (ThreadPools) Context.get().getBean(ThreadPools.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,13 @@ public static EMail messageToMail(javax.mail.Message msg, boolean extractAttachm
int count = multipart.getCount();
for (int i = 1; i < count; i++) {
BodyPart bp = multipart.getBodyPart(i);
if(bp.getFileName()!=null && bp.getFileName().toLowerCase().contains(".p7s")) {
MimeBodyPart smimeBody = SmimeUtil.getSignedContent(multipart);

if (bp.getFileName() != null && bp.getFileName().toLowerCase().contains(".p7s")) {
MimeBodyPart smimeBody = SmimeUtil.getSignedContent(multipart);
addAttachments(smimeBody, email, extractAttachmentContent);
}else
addAttachments(bp, email, extractAttachmentContent);
} else {
addAttachments(bp, email, extractAttachmentContent);
}
}
} else if (NO_BODY.equals(email.getMessageText())) {
// This is not a multipart message and if there is no text, perhaps
Expand All @@ -351,7 +352,7 @@ public static EMail messageToMail(javax.mail.Message msg, boolean extractAttachm

return email;
}

private static void setReplyTo(javax.mail.Message msg, EMail email) throws MessagingException {
Address[] addresses = msg.getReplyTo();
if (addresses != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public abstract class AbstractFormatConverter implements FormatConverter {

protected Map<String, String> parameters = new HashMap<>();

public AbstractFormatConverter() {
protected AbstractFormatConverter() {
loadParameters();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class Dashlet extends PersistentObject {
public Dashlet() {
}

public Dashlet(Dashlet source) {
protected Dashlet(Dashlet source) {
super();
this.type = source.type;
this.query = source.query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import org.java.plugin.registry.Extension;
Expand Down Expand Up @@ -45,17 +44,15 @@ public void init(String[] ids) {
for (Extension extension : exts) {
sortedExts.add(extension);
}
Collections.sort(sortedExts, new Comparator<Extension>() {
public int compare(Extension e1, Extension e2) {
int position1 = Integer.parseInt(e1.getParameter("position").valueAsString());
int position2 = Integer.parseInt(e2.getParameter("position").valueAsString());
if (position1 < position2)
return -1;
else if (position1 > position2)
return 1;
else
return 0;
}
Collections.sort(sortedExts, (Extension e1, Extension e2) -> {
int position1 = Integer.parseInt(e1.getParameter("position").valueAsString());
int position2 = Integer.parseInt(e2.getParameter("position").valueAsString());
if (position1 < position2)
return -1;
else if (position1 > position2)
return 1;
else
return 0;
});

getSqlList().clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public abstract class AbstractDocument extends ExtensibleObject implements Trans
*/
private int ocrd = 0;

public AbstractDocument() {
protected AbstractDocument() {
super();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,30 +337,26 @@ else if (comp != null && !asc)
}

public static Comparator<AbstractDocument> getComparator(List<DocumentComparator> multipleOptions) {
return new Comparator<AbstractDocument>() {
public int compare(AbstractDocument d1, AbstractDocument d2) {
for (DocumentComparator option : multipleOptions) {
int result = option.compare(d1, d2);
if (result != 0) {
return result;
}
return (d1, d2) -> {
for (DocumentComparator option : multipleOptions) {
int result = option.compare(d1, d2);
if (result != 0) {
return result;
}
return 0;
}
return 0;
};
}

public static Comparator<AbstractDocument> getComparator(final DocumentComparator... multipleOptions) {
return new Comparator<AbstractDocument>() {
public int compare(AbstractDocument d1, AbstractDocument d2) {
for (DocumentComparator option : multipleOptions) {
int result = option.compare(d1, d2);
if (result != 0) {
return result;
}
return (d1, d2) -> {
for (DocumentComparator option : multipleOptions) {
int result = option.compare(d1, d2);
if (result != 0) {
return result;
}
return 0;
}
return 0;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

import org.java.plugin.registry.Extension;
Expand All @@ -20,7 +19,7 @@
* @since 4.0
*/
public class DocumentListenerManager {

private static final String POSITION = "position";

protected static Logger log = LoggerFactory.getLogger(DocumentListenerManager.class);
Expand All @@ -41,17 +40,15 @@ public synchronized void init() {
for (Extension extension : exts) {
sortedExts.add(extension);
}
Collections.sort(sortedExts, new Comparator<Extension>() {
public int compare(Extension e1, Extension e2) {
int position1 = Integer.parseInt(e1.getParameter(POSITION).valueAsString());
int position2 = Integer.parseInt(e2.getParameter(POSITION).valueAsString());
if (position1 < position2)
return -1;
else if (position1 > position2)
return 1;
else
return 0;
}
Collections.sort(sortedExts, (Extension e1, Extension e2) -> {
int position1 = Integer.parseInt(e1.getParameter(POSITION).valueAsString());
int position2 = Integer.parseInt(e2.getParameter(POSITION).valueAsString());
if (position1 < position2)
return -1;
else if (position1 > position2)
return 1;
else
return 0;
});

for (Extension ext : sortedExts) {
Expand Down
Loading

0 comments on commit 46293f1

Please sign in to comment.