Skip to content

Commit 5d4b5ec

Browse files
authored
chore: Remove classes with very few constants (#406)
1 parent 95d3a7c commit 5d4b5ec

File tree

7 files changed

+9
-57
lines changed

7 files changed

+9
-57
lines changed

cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/configuration/Registration.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import com.sap.cds.feature.attachments.service.malware.client.DefaultMalwareScanClient;
4040
import com.sap.cds.feature.attachments.service.malware.client.httpclient.MalwareScanClientProviderFactory;
4141
import com.sap.cds.feature.attachments.service.malware.client.mapper.DefaultMalwareClientStatusMapper;
42-
import com.sap.cds.feature.attachments.service.malware.constants.MalwareScanConstants;
4342
import com.sap.cds.services.ServiceCatalog;
4443
import com.sap.cds.services.cds.ApplicationService;
4544
import com.sap.cds.services.draft.DraftService;
@@ -91,7 +90,7 @@ public void eventHandlers(CdsRuntimeConfigurer configurer) {
9190

9291
// retrieve the service binding for the malware scanner service
9392
List<ServiceBinding> bindings = environment.getServiceBindings()
94-
.filter(b -> ServiceBindingUtils.matches(b, MalwareScanConstants.MALWARE_SCAN_SERVICE_LABEL)).toList();
93+
.filter(b -> ServiceBindingUtils.matches(b, DefaultAttachmentMalwareScanner.MALWARE_SCAN_SERVICE_LABEL)).toList();
9594
var binding = !bindings.isEmpty() ? bindings.get(0) : null;
9695

9796
// get HTTP connection pool configuration

cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/common/ApplicationHandlerHelper.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import com.sap.cds.CdsDataProcessor.Filter;
1717
import com.sap.cds.CdsDataProcessor.Validator;
1818
import com.sap.cds.feature.attachments.generated.cds4j.sap.attachments.Attachments;
19-
import com.sap.cds.feature.attachments.handler.constants.ModelConstants;
2019
import com.sap.cds.reflect.CdsElement;
2120
import com.sap.cds.reflect.CdsEntity;
2221
import com.sap.cds.reflect.CdsStructuredType;
@@ -26,13 +25,15 @@
2625
* The class {@link ApplicationHandlerHelper} provides helper methods for the attachment application handlers.
2726
*/
2827
public final class ApplicationHandlerHelper {
28+
private static final String ANNOTATION_IS_MEDIA_DATA = "_is_media_data";
29+
private static final String ANNOTATION_CORE_MEDIA_TYPE = "Core.MediaType";
2930

3031
/**
3132
* A filter for media content fields. The filter checks if the entity is a media entity and if the element has the
3233
* annotation "Core.MediaType".
3334
*/
3435
public static final Filter MEDIA_CONTENT_FILTER = (path, element, type) -> isMediaEntity(path.target().type())
35-
&& hasElementAnnotation(element, ModelConstants.ANNOTATION_CORE_MEDIA_TYPE);
36+
&& hasElementAnnotation(element, ANNOTATION_CORE_MEDIA_TYPE);
3637

3738
/**
3839
* Checks if the data contains a content field.
@@ -65,7 +66,7 @@ public static void callValidator(CdsEntity entity, List<CdsData> data, Filter fi
6566
* @return <code>true</code> if the entity is a media entity, <code>false</code> otherwise
6667
*/
6768
public static boolean isMediaEntity(CdsStructuredType baseEntity) {
68-
return baseEntity.getAnnotationValue(ModelConstants.ANNOTATION_IS_MEDIA_DATA, false);
69+
return baseEntity.getAnnotationValue(ANNOTATION_IS_MEDIA_DATA, false);
6970
}
7071

7172
public static boolean doesContentIdExistsBefore(Map<?, Object> existingData) {

cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/handler/constants/ModelConstants.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/service/malware/DefaultAttachmentMalwareScanner.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
*/
3535
public class DefaultAttachmentMalwareScanner implements AttachmentMalwareScanner {
3636

37+
public static final String MALWARE_SCAN_SERVICE_LABEL = "malware-scanner";
38+
3739
private static final Logger logger = LoggerFactory.getLogger(DefaultAttachmentMalwareScanner.class);
3840
private final PersistenceService persistenceService;
3941
private final AttachmentService attachmentService;

cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/service/malware/client/httpclient/MalwareScanClientProviderFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import org.apache.http.client.HttpClient;
1010

11-
import com.sap.cds.feature.attachments.service.malware.constants.MalwareScanConstants;
11+
import com.sap.cds.feature.attachments.service.malware.DefaultAttachmentMalwareScanner;
1212
import com.sap.cds.services.environment.CdsProperties.ConnectionPool;
1313
import com.sap.cloud.environment.servicebinding.api.ServiceBinding;
1414
import com.sap.cloud.sdk.cloudplatform.connectivity.DefaultHttpClientFactory;
@@ -36,7 +36,7 @@ public MalwareScanClientProviderFactory(ServiceBinding binding, ConnectionPool c
3636
var url = (String) credentials.get(VALUE_URL);
3737
var serviceUrl = URI.create(url + SCAN_ENDPOINT).normalize();
3838
var basic = new BasicCredentials((String) credentials.get(VALUE_USERNAME), (String) credentials.get(VALUE_PASSWORD));
39-
var destination = DefaultHttpDestination.builder(serviceUrl).name(MalwareScanConstants.MALWARE_SCAN_SERVICE_LABEL)
39+
var destination = DefaultHttpDestination.builder(serviceUrl).name(DefaultAttachmentMalwareScanner.MALWARE_SCAN_SERVICE_LABEL)
4040
.basicCredentials(basic).build();
4141

4242
DefaultHttpClientFactoryBuilder builder = DefaultHttpClientFactory.builder();

cds-feature-attachments/src/main/java/com/sap/cds/feature/attachments/service/malware/constants/MalwareScanConstants.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

cds-feature-attachments/src/test/java/com/sap/cds/feature/attachments/handler/constants/ModelConstantsTest.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)