Created
June 19, 2018 18:52
-
-
Save maxymania/9f7f2af5deaa882db1b254f81a32d2d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2018 Simon Schmidt | |
*/ | |
package webidee.cmistests.serializers.old; | |
import com.esotericsoftware.kryo.Kryo; | |
import com.esotericsoftware.kryo.Serializer; | |
import com.esotericsoftware.kryo.io.Input; | |
import com.esotericsoftware.kryo.io.Output; | |
import java.util.List; | |
import java.util.Map; | |
import org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionElementImpl; | |
/** | |
* | |
* @author Simon Schmidt | |
*/ | |
public class CEEISerializer extends Serializer<CmisExtensionElementImpl> { | |
@Override | |
public void write(Kryo kryo, Output output, CmisExtensionElementImpl t) { | |
Object v = t.getValue(); | |
if(v==null) v = t.getChildren(); | |
kryo.writeObjectOrNull(output, t.getNamespace(), String.class); | |
kryo.writeObject(output, t.getName()); | |
kryo.writeClassAndObject(output, t.getAttributes()); | |
kryo.writeClassAndObject(output, v); | |
} | |
@Override | |
public CmisExtensionElementImpl read(Kryo kryo, Input input, Class<? extends CmisExtensionElementImpl> type) { | |
if(type!=CmisExtensionElementImpl.class)throw new IllegalStateException(); | |
String namespace = kryo.readObjectOrNull(input, String.class); | |
String name = kryo.readObject(input, String.class); | |
Map<String,String> attrs = (Map)kryo.readClassAndObject(input); | |
Object v = kryo.readClassAndObject(input); | |
if(v instanceof String) | |
return new CmisExtensionElementImpl(namespace,name,attrs,(String)v); | |
return new CmisExtensionElementImpl(namespace,name,attrs,(List)v); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2018 Simon Schmidt | |
*/ | |
package webidee.cmistests.serializers.old; | |
import com.esotericsoftware.kryo.Kryo; | |
import com.esotericsoftware.kryo.Serializer; | |
import com.esotericsoftware.kryo.io.Input; | |
import com.esotericsoftware.kryo.io.Output; | |
import java.util.List; | |
import org.apache.chemistry.opencmis.commons.data.MutableAce; | |
import org.apache.chemistry.opencmis.commons.impl.dataobjects.AccessControlPrincipalDataImpl; | |
/** | |
* | |
* @author Simon Schmidt | |
*/ | |
public class MAceSerializer extends Serializer<MutableAce> { | |
@Override | |
public void write(Kryo kryo, Output output, MutableAce t) { | |
kryo.writeObject(output, t.isDirect()); | |
kryo.writeClassAndObject(output, t.getExtensions()); | |
kryo.writeClassAndObject(output, t.getPermissions()); | |
kryo.writeObjectOrNull(output, t.getPrincipalId(), String.class); | |
} | |
@Override | |
public MutableAce read(Kryo kryo, Input input, Class<? extends MutableAce> type) { | |
MutableAce t = kryo.newInstance(type); | |
t.setDirect(kryo.readObject(input, Boolean.class)); | |
t.setExtensions((List)kryo.readClassAndObject(input)); | |
t.setPermissions((List)kryo.readClassAndObject(input)); | |
String p = kryo.readObjectOrNull(input, String.class); | |
t.setPrincipal(p!=null?new AccessControlPrincipalDataImpl(p):null); | |
return t; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2018 Simon Schmidt | |
*/ | |
package webidee.cmistests.serializers.old; | |
import com.esotericsoftware.kryo.Kryo; | |
import com.esotericsoftware.kryo.Serializer; | |
import com.esotericsoftware.kryo.io.Input; | |
import com.esotericsoftware.kryo.io.Output; | |
import java.util.List; | |
import org.apache.chemistry.opencmis.commons.data.MutableAcl; | |
/** | |
* | |
* @author Simon Schmidt | |
*/ | |
public class MAclSerializer extends Serializer<MutableAcl> { | |
@Override | |
public void write(Kryo kryo, Output output, MutableAcl t) { | |
kryo.writeClassAndObject(output, t.getAces()); | |
kryo.writeObjectOrNull(output, t.isExact(), Boolean.class); | |
kryo.writeClassAndObject(output, t.getExtensions()); | |
} | |
@Override | |
public MutableAcl read(Kryo kryo, Input input, Class<? extends MutableAcl> type) { | |
MutableAcl t = kryo.newInstance(type); | |
t.setAces((List)kryo.readClassAndObject(input)); | |
t.setExact(kryo.readObjectOrNull(input, Boolean.class)); | |
t.setExtensions((List)kryo.readClassAndObject(input)); | |
return t; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2018 Simon Schmidt | |
*/ | |
package webidee.cmistests.serializers.old; | |
import com.esotericsoftware.kryo.Kryo; | |
import com.esotericsoftware.kryo.Serializer; | |
import com.esotericsoftware.kryo.io.Input; | |
import com.esotericsoftware.kryo.io.Output; | |
import java.util.Collections; | |
import java.util.List; | |
import org.apache.chemistry.opencmis.commons.data.MutablePropertyData; | |
/** | |
* | |
* @author Simon Schmidt | |
*/ | |
public class PropSerializer<T> extends Serializer<MutablePropertyData<T>> { | |
private static List e2n(List l){ | |
if(l==null)return null; | |
if(l.isEmpty())return null; | |
return l; | |
} | |
private static List dec(List l){ | |
if(l==null) return Collections.emptyList(); | |
return l; | |
} | |
@Override | |
public void write(Kryo kryo, Output output, MutablePropertyData<T> t) { | |
kryo.writeObjectOrNull(output, t.getDisplayName(), String.class); | |
kryo.writeObjectOrNull(output, t.getId(), String.class); | |
kryo.writeObjectOrNull(output, t.getLocalName(), String.class); | |
kryo.writeObjectOrNull(output, t.getQueryName(), String.class); | |
kryo.writeClassAndObject(output, e2n(t.getValues())); | |
kryo.writeClassAndObject(output, t.getExtensions()); | |
} | |
@Override | |
public MutablePropertyData<T> read(Kryo kryo, Input input, Class<? extends MutablePropertyData<T>> type) { | |
MutablePropertyData<T> t = kryo.newInstance(type); | |
t.setDisplayName(kryo.readObjectOrNull(input, String.class)); | |
t.setId(kryo.readObjectOrNull(input, String.class)); | |
t.setLocalName(kryo.readObjectOrNull(input, String.class)); | |
t.setQueryName(kryo.readObjectOrNull(input, String.class)); | |
t.setValues(dec((List)kryo.readClassAndObject(input))); | |
t.setExtensions((List)kryo.readClassAndObject(input)); | |
return t; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment