From 8bef2bb78401e6c52b6b629f7a11b21bfe5ecdff Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sat, 3 Dec 2022 18:06:44 +0100 Subject: [PATCH] Code cleanup --- .../org/librecms/assets/ContactEntry.java | 2 - .../ContactEntryKeyJsonDeserializer.java | 61 ------------------- .../assets/ContactEntryKeyJsonSerializer.java | 43 ------------- 3 files changed, 106 deletions(-) delete mode 100644 ccm-cms/src/main/java/org/librecms/assets/ContactEntryKeyJsonDeserializer.java delete mode 100644 ccm-cms/src/main/java/org/librecms/assets/ContactEntryKeyJsonSerializer.java diff --git a/ccm-cms/src/main/java/org/librecms/assets/ContactEntry.java b/ccm-cms/src/main/java/org/librecms/assets/ContactEntry.java index 7e712ee10..4e2b49242 100644 --- a/ccm-cms/src/main/java/org/librecms/assets/ContactEntry.java +++ b/ccm-cms/src/main/java/org/librecms/assets/ContactEntry.java @@ -65,8 +65,6 @@ public class ContactEntry implements Serializable { // @Column(name = "ENTRY_KEY", length = 255, nullable = false) @OneToOne @JoinColumn(name = "CONTACT_ENTRY_KEY_ID") -// @JsonSerialize(using = ContactEntryKeyJsonSerializer.class) -// @JsonDeserialize(using = ContactEntryKeyJsonDeserializer.class) private ContactEntryKey key; /** diff --git a/ccm-cms/src/main/java/org/librecms/assets/ContactEntryKeyJsonDeserializer.java b/ccm-cms/src/main/java/org/librecms/assets/ContactEntryKeyJsonDeserializer.java deleted file mode 100644 index 3738014dc..000000000 --- a/ccm-cms/src/main/java/org/librecms/assets/ContactEntryKeyJsonDeserializer.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2022 LibreCCM Foundation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301 USA - */ -package org.librecms.assets; - -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.DeserializationContext; -import com.fasterxml.jackson.databind.JsonDeserializer; -import org.libreccm.cdi.utils.CdiUtil; - -import java.io.IOException; -import java.util.Optional; - -/** - * - * @author Jens Pelzetter - */ -public class ContactEntryKeyJsonDeserializer - extends JsonDeserializer { - - @Override - public ContactEntryKey deserialize( - final JsonParser parser, - final DeserializationContext ctxt - ) throws IOException, JsonProcessingException { - final String key = parser.getText(); - - final ContactEntryKeyRepository entryKeyRepo = CdiUtil - .createCdiUtil() - .findBean(ContactEntryKeyRepository.class); - final Optional result = entryKeyRepo - .findByEntryKey(key); - - if (result.isPresent()) { - return result.get(); - } else { - final ContactEntryKey entryKey = new ContactEntryKey(); - entryKey.setEntryKey(key); - entryKeyRepo.save(entryKey); - - return entryKey; - } - } - -} diff --git a/ccm-cms/src/main/java/org/librecms/assets/ContactEntryKeyJsonSerializer.java b/ccm-cms/src/main/java/org/librecms/assets/ContactEntryKeyJsonSerializer.java deleted file mode 100644 index 2b0768a7e..000000000 --- a/ccm-cms/src/main/java/org/librecms/assets/ContactEntryKeyJsonSerializer.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (C) 2022 LibreCCM Foundation. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301 USA - */ -package org.librecms.assets; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.SerializerProvider; - -import java.io.IOException; - -/** - * - * @author Jens Pelzetter - */ -public class ContactEntryKeyJsonSerializer - extends JsonSerializer { - - @Override - public void serialize( - final ContactEntryKey value, - final JsonGenerator generator, - final SerializerProvider serializers - ) throws IOException { - generator.writeStringField("key", value.getEntryKey()); - } - -}