Code cleanup
parent
38dae9a6bf
commit
8bef2bb784
|
|
@ -65,8 +65,6 @@ public class ContactEntry implements Serializable {
|
||||||
// @Column(name = "ENTRY_KEY", length = 255, nullable = false)
|
// @Column(name = "ENTRY_KEY", length = 255, nullable = false)
|
||||||
@OneToOne
|
@OneToOne
|
||||||
@JoinColumn(name = "CONTACT_ENTRY_KEY_ID")
|
@JoinColumn(name = "CONTACT_ENTRY_KEY_ID")
|
||||||
// @JsonSerialize(using = ContactEntryKeyJsonSerializer.class)
|
|
||||||
// @JsonDeserialize(using = ContactEntryKeyJsonDeserializer.class)
|
|
||||||
private ContactEntryKey key;
|
private ContactEntryKey key;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ContactEntryKeyJsonDeserializer
|
|
||||||
extends JsonDeserializer<ContactEntryKey> {
|
|
||||||
|
|
||||||
@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<ContactEntryKey> result = entryKeyRepo
|
|
||||||
.findByEntryKey(key);
|
|
||||||
|
|
||||||
if (result.isPresent()) {
|
|
||||||
return result.get();
|
|
||||||
} else {
|
|
||||||
final ContactEntryKey entryKey = new ContactEntryKey();
|
|
||||||
entryKey.setEntryKey(key);
|
|
||||||
entryKeyRepo.save(entryKey);
|
|
||||||
|
|
||||||
return entryKey;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
|
||||||
*/
|
|
||||||
public class ContactEntryKeyJsonSerializer
|
|
||||||
extends JsonSerializer<ContactEntryKey> {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void serialize(
|
|
||||||
final ContactEntryKey value,
|
|
||||||
final JsonGenerator generator,
|
|
||||||
final SerializerProvider serializers
|
|
||||||
) throws IOException {
|
|
||||||
generator.writeStringField("key", value.getEntryKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue