Skip to content

Commit

Permalink
Fix checkstyle issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy Teeuwen committed Sep 25, 2023
1 parent c4a6173 commit 3a411d7
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/*
* ACS AEM Commons
*
* Copyright (C) 2013 - 2023 Adobe
*
* #%L
* ACS AEM Commons Bundle
* %%
* Copyright (C) 2016 Adobe
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -14,6 +15,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.adobe.acs.commons.replication.dispatcher.impl;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,49 @@
/*
* #%L
* ACS AEM Commons Bundle
* %%
* Copyright (C) 2016 Adobe
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.adobe.acs.commons.replication.dispatcher.impl;

import com.adobe.acs.commons.replication.dispatcher.DispatcherFlushFilter;
import com.adobe.acs.commons.replication.dispatcher.DispatcherFlusher;
import com.day.cq.replication.*;
import com.day.cq.replication.Agent;
import com.day.cq.replication.AgentFilter;
import com.day.cq.replication.AgentManager;
import com.day.cq.replication.ReplicationActionType;
import com.day.cq.replication.ReplicationException;
import com.day.cq.replication.ReplicationResult;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.distribution.*;
import org.apache.sling.distribution.DistributionRequest;
import org.apache.sling.distribution.DistributionRequestType;
import org.apache.sling.distribution.DistributionResponse;
import org.apache.sling.distribution.Distributor;
import org.apache.sling.distribution.SimpleDistributionRequest;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.propertytypes.ServiceRanking;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
@ServiceRanking(-5000)
Expand Down Expand Up @@ -41,19 +73,12 @@ public Map<Agent, ReplicationResult> flush(ResourceResolver resourceResolver, St
return result;
}

private ReplicationResult toReplicationResult(DistributionResponse distributionResponse) {
if (distributionResponse.isSuccessful()) {
return ReplicationResult.OK;
}
return new ReplicationResult(false, 500, distributionResponse.getMessage());
}

@Override
public Map<Agent, ReplicationResult> flush(ResourceResolver resourceResolver, ReplicationActionType actionType, boolean synchronous, String... paths) throws ReplicationException {
// see https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/implementing/content-delivery/caching.html?lang=en#sling-distribution
log.warn(
"Dispatcher flusher in cloud should use INVALIDATE distribution types from author, no custom action type and synchronous should be set, " +
"refactor your code to use the DispatcherFlushRules.flush(resourceResolver, paths) method"
"Dispatcher flusher in cloud should use INVALIDATE distribution types from author, no custom action type and synchronous should be set, "
+ "refactor your code to use the DispatcherFlushRules.flush(resourceResolver, paths) method"
);
return flush(resourceResolver, paths);
}
Expand All @@ -62,19 +87,21 @@ public Map<Agent, ReplicationResult> flush(ResourceResolver resourceResolver, Re
public Map<Agent, ReplicationResult> flush(ResourceResolver resourceResolver, ReplicationActionType actionType, boolean synchronous, AgentFilter agentFilter, String... paths) throws ReplicationException {
// see https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/implementing/content-delivery/caching.html?lang=en#sling-distribution
log.warn(
"Dispatcher flusher in cloud should use INVALIDATE distribution types from author, no custom action type and synchronous should be set, " +
"refactor your code to use the DispatcherFlushRules.flush(resourceResolver, paths) method"
"Dispatcher flusher in cloud should use INVALIDATE distribution types from author, no custom action type and synchronous should be set, "
+ "refactor your code to use the DispatcherFlushRules.flush(resourceResolver, paths) method"
);
return flush(resourceResolver, paths);
}

@Override
public final Agent[] getFlushAgents() {
return this.getAgents(new DispatcherFlushFilter());
}

/**
* {@inheritDoc}
*/
@Override
public final Agent[] getAgents(final AgentFilter agentFilter) {
final List<Agent> flushAgents = new ArrayList<Agent>();

Expand All @@ -85,4 +112,11 @@ public final Agent[] getAgents(final AgentFilter agentFilter) {
}
return flushAgents.toArray(new Agent[flushAgents.size()]);
}

private ReplicationResult toReplicationResult(DistributionResponse distributionResponse) {
if (distributionResponse.isSuccessful()) {
return ReplicationResult.OK;
}
return new ReplicationResult(false, 500, distributionResponse.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/*
* ACS AEM Commons
*
* Copyright (C) 2013 - 2023 Adobe
*
* #%L
* ACS AEM Commons Bundle
* %%
* Copyright (C) 2016 Adobe
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -14,6 +15,7 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package com.adobe.acs.commons.replication.dispatcher;

Expand Down

0 comments on commit 3a411d7

Please sign in to comment.