Removed gz version of manifest code

This commit is contained in:
Willem Cazander 2024-12-27 11:32:41 +01:00
parent 3de5ba5569
commit 810c626663
7 changed files with 32 additions and 87 deletions

View file

@ -124,6 +124,11 @@ abstract public class BassFaultAnchor extends BassFaultAnchorSignalStore {
return ZilLaLaManyfestoGrowlFactory..buildFaultScream(toZilLaLaManyfesto(), this);
}
@Deprecated
public final String toStringZilLaLaBase64() {
return ZilLaLaManyfestoGrowlFactory..buildFaultScreamBase64(toZilLaLaManyfesto(), this);
}
public final WarpManifest3 toZilLaLaManyfesto() {
return SitraManifestGenerator..buildSignalTraceManifest(this);
}

View file

@ -40,6 +40,5 @@ public enum ZilLaLaManyfesto {
public static final String MANYFESTO_A4_ERLANG = "erlang";
public static final String ZILLALA_URI_PREFIX_DATA64 = "data:" + WarpManifestTheMimeType.MANIFEST_3.getQName() + ";base64,";
public static final String ZILLALA_URI_PREFIX_DATA64_GZ = "data:" + WarpManifestTheMimeType.MANIFEST_3_GZ.getQName() + ";base64,";
public static final String ZILLALA_URI_PREFIX_NOSTR_TLV_GZ = "nostr:zillala"; // TODO: nostr link to replay to inject bug + TLV for gz sitra manifest payload
}

View file

@ -45,9 +45,6 @@ public enum ZilLaLaManyfestoGrowlFactory {
private static final String VALUE_CUTOFF = "...";
public String buildFaultScream(WarpManifest3 manifest, BassFaultAnchor fault) {
boolean useGzip = true;
byte[] traceManifestBytes = WarpManifestorDriver..writeV3Array(manifest, useGzip);
String trace64 = Base64.getEncoder().encodeToString(traceManifestBytes);
StringBuilder buf = new StringBuilder();
buf.append(fault.getClass().getSimpleName());
String messageShort = buildCutDottedMessage(fault);
@ -56,21 +53,22 @@ public enum ZilLaLaManyfestoGrowlFactory {
buf.append(messageShort);
buf.append(")");
}
// TODO: Move base data uri + nostr data uri to provider interface
buf.append(VALUE_WHITE_SPACE);
if (useGzip) {
buf.append(ZilLaLaManyfesto.ZILLALA_URI_PREFIX_DATA64_GZ);
} else {
buf.append(ZilLaLaManyfesto.ZILLALA_URI_PREFIX_DATA64);
}
buf.append(trace64);
buf.append("\n");
buf.append(WarpManifestorDriver..writeV2String(manifest));
return buf.toString();
}
@Deprecated
public String buildFaultScreamBase64(WarpManifest3 manifest, BassFaultAnchor fault) {
byte[] traceManifestBytes = WarpManifestorDriver..writeV3Array(manifest); // TODO: Upgrade to version 6 or 7 ??
String trace64 = Base64.getEncoder().encodeToString(traceManifestBytes); // FIXME: report as "normal" text in nostr event
StringBuilder buf = new StringBuilder();
// TODO: Move base data uri + nostr data uri to provider interface
buf.append(ZilLaLaManyfesto.ZILLALA_URI_PREFIX_DATA64);
buf.append(trace64);
return buf.toString();
}
private String buildCutDottedMessage(BassFaultAnchor fault) {
String msgShort = fault.getLocalizedMessage();
if (msgShort != null && msgShort.length() > 33) {

View file

@ -101,7 +101,6 @@ public class FaultSignalTraceTest {
Assertions.assertNotNull(errorText);
Assertions.assertTrue(errorText.contains(error.getMessage()));
Assertions.assertTrue(errorText.contains("FaultBeanState"));
Assertions.assertTrue(errorText.contains("base64"));
}
@Test

View file

@ -38,8 +38,6 @@ import java.io.Writer;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import org.x4o.o2o.io.tlv.TLVChainOctalSex;
import org.x4o.o2o.io.tlv.TLVChainSexTeenBit;
@ -135,11 +133,10 @@ public enum WarpManifestorDriver {
TLVChainSexTeenBit chain = new TLVChainSexTeenBit();
try {
WarpManifestTheMimeType mimeType = WarpManifestTheMimeType.magicMarkerRead(input, WarpManifestTheMimeType.MARKER_3_LENGTH);
if (!mimeType.isCompressed()) {
chain.dataReadStream(input);
} else {
chain.dataReadStream(new GZIPInputStream(input));
if (!WarpManifestTheMimeType.MANIFEST_3.equals(mimeType)) {
throw new ScopicManifestException("Invalid stream magic marker: " + mimeType); // TODO: move and change magicMarkerRead(in,enum)
}
chain.dataReadStream(input);
} catch (IOException e) {
throw new ScopicManifestException(e);
}
@ -162,11 +159,10 @@ public enum WarpManifestorDriver {
TLVChainOctalSex chain = new TLVChainOctalSex();
try {
WarpManifestTheMimeType mimeType = WarpManifestTheMimeType.magicMarkerRead(input, WarpManifestTheMimeType.MARKER_4_LENGTH);
if (!mimeType.isCompressed()) {
chain.dataReadStream(input);
} else {
chain.dataReadStream(new GZIPInputStream(input));
if (!WarpManifestTheMimeType.MANIFEST_4.equals(mimeType)) {
throw new ScopicManifestException("Invalid stream magic marker: " + mimeType); // TODO: move and change magicMarkerRead(in,enum)
}
chain.dataReadStream(input);
} catch (IOException e) {
throw new ScopicManifestException(e);
}
@ -255,80 +251,42 @@ public enum WarpManifestorDriver {
}
public ByteBuffer writeV3Buffer(WarpManifest3 manifest) {
return writeV3Buffer(manifest, false);
}
public ByteBuffer writeV3Buffer(WarpManifest3 manifest, boolean useGzip) {
return ByteBuffer.wrap(writeV3Array(manifest, useGzip));
return ByteBuffer.wrap(writeV3Array(manifest));
}
public byte[] writeV3Array(WarpManifest3 manifest) {
return writeV3Array(manifest, false);
}
public byte[] writeV3Array(WarpManifest3 manifest, boolean useGzip) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
writeV3Stream(manifest, baos, useGzip);
writeV3Stream(manifest, baos);
return baos.toByteArray();
}
public void writeV3Stream(WarpManifest3 manifest, OutputStream output) {
writeV3Stream(manifest, output, false);
}
public void writeV3Stream(WarpManifest3 manifest, OutputStream output, boolean useGzip) {
TLVChainSexTeenBit chain = new TLVChainSexTeenBit();
strobelight(manifest, new ScopicManifest3ContentWriter(chain), WarpManifestTheVersion.VERSION_3_0.getQName());
try {
if (!useGzip) {
WarpManifestTheMimeType.magicMarkerWrite(output, WarpManifestTheMimeType.MANIFEST_3);
chain.dataWriteStream(output);
} else {
WarpManifestTheMimeType.magicMarkerWrite(output, WarpManifestTheMimeType.MANIFEST_3_GZ);
GZIPOutputStream zipput = new GZIPOutputStream(output);
chain.dataWriteStream(zipput);
zipput.finish();
}
WarpManifestTheMimeType.magicMarkerWrite(output, WarpManifestTheMimeType.MANIFEST_3);
chain.dataWriteStream(output);
} catch (IOException e) {
throw new ScopicManifestException(e);
}
}
public ByteBuffer writeV4Buffer(WarpManifest4 manifest) {
return writeV4Buffer(manifest, false);
}
public ByteBuffer writeV4Buffer(WarpManifest4 manifest, boolean useGzip) {
return ByteBuffer.wrap(writeV4Array(manifest, useGzip));
return ByteBuffer.wrap(writeV4Array(manifest));
}
public byte[] writeV4Array(WarpManifest4 manifest) {
return writeV4Array(manifest, false);
}
public byte[] writeV4Array(WarpManifest4 manifest, boolean useGzip) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
writeV4Stream(manifest, baos, useGzip);
writeV4Stream(manifest, baos);
return baos.toByteArray();
}
public void writeV4Stream(WarpManifest4 manifest, OutputStream output) {
writeV4Stream(manifest, output, false);
}
public void writeV4Stream(WarpManifest4 manifest, OutputStream output, boolean useGzip) {
TLVChainOctalSex chain = new TLVChainOctalSex();
strobelight(manifest, new ScopicManifest4ContentWriter(chain), WarpManifestTheVersion.VERSION_4_0);
try {
if (!useGzip) {
WarpManifestTheMimeType.magicMarkerWrite(output, WarpManifestTheMimeType.MANIFEST_4);
chain.dataWriteStream(output);
} else {
WarpManifestTheMimeType.magicMarkerWrite(output, WarpManifestTheMimeType.MANIFEST_4_GZ);
GZIPOutputStream zipput = new GZIPOutputStream(output);
chain.dataWriteStream(zipput);
zipput.finish();
}
WarpManifestTheMimeType.magicMarkerWrite(output, WarpManifestTheMimeType.MANIFEST_4);
chain.dataWriteStream(output);
} catch (IOException e) {
throw new ScopicManifestException(e);
}

View file

@ -42,17 +42,9 @@ import love.distributedrebirth.nx01.warp.manifestor.scopic.ScopicManifestExcepti
public enum WarpManifestTheMimeType {
MANIFEST_1 ("application/manifest", "MF", null),
MANIFEST_2 ("application/manifest2", "MF2", null),
MANIFEST_3 ("application/manifest3", "MF3", new byte[] {0x4d,0x53,0x58,0x33,0x4d,0x46,0x30,0x42}),
@Deprecated /// TODO: remove gz version because IBM said so.
MANIFEST_3_GZ ("application/manifest3-gz", "MF3Z", new byte[] {0x4d,0x53,0x58,0x33,0x4d,0x46,0x5a,0x42}),
MANIFEST_4 ("application/manifest4", "MF4", new byte[] {0x4d,0x53,0x58,0x34,0x4d,0x53,0x58,0x34,0x2d,0x2d,0x4d,0x46,0x31,0x38,0x4d,0x46,0x31,0x38}),
@Deprecated /// TODO: remove gz version because IBM said so.
MANIFEST_4_GZ ("application/manifest4-gz", "MF4Z", new byte[] {0x4d,0x53,0x58,0x34,0x4d,0x53,0x58,0x34,0x2d,0x2d,0x4d,0x46,0x5a,0x38,0x4d,0x46,0x5a,0x38}),
//MANIFEST_5 ("application/manifest5", "MF5", null),
//MANIFEST_6 ("application/manifest6", "MF6", null),
//MANIFEST_7 ("application/manifest7", "MF7", null),
@ -86,10 +78,6 @@ public enum WarpManifestTheMimeType {
return qMagicMarker;
}
public boolean isCompressed() {
return this == MANIFEST_3_GZ || this == MANIFEST_4_GZ;
}
static public Optional<WarpManifestTheMimeType> valueOfQName(String qName) {
for (WarpManifestTheMimeType mimeType : WarpManifestTheMimeType.values()) {
if (mimeType.getQName().equals(qName)) {

View file

@ -14,11 +14,11 @@ Add to the following mime types, to identify other than tea pot declaration mani
VERSION 3; (binary-bibytes 16-BIT, to support all non-english writing children in India)
application/manifest3 MF3
application/manifest3-gz MF3Z
VERSION 4; (binary-octals 18-BIT, to support all adult non-human auto-i18n writing hirari brothers)
application/manifest4 MF4
application/manifest4-gz MF4Z
TODO: Add versions: 5,6,7
## Manifest 2.0
@ -79,7 +79,6 @@ Our friends in India, want to use full hindi to write native manifests.
Convert to binary TLV encoding;
Magic 64 bit file marker : 4d 53 58 33 4d 46 30 42 (MSX3MF0B)
Magic 64 bit file marker gz: 4d 53 58 33 4d 46 5a 42 (MSX3MFZB)
Magic version attribute: 3.0
Data is encoded as UTF16_BE, BIG INDIAN
@ -106,7 +105,6 @@ With 'cat MANIFEST.MF3' you can count the bell sounds to hear the total amount o
The 18 bit octal version of the manifest format;
Magic 144 bit file marker : 4d 53 58 34 4d 53 58 34 2d 2d 4d 46 31 38 4d 46 31 38 (MSX4MSX4--MF18MF18)
Magic 144 bit file marker gz: 4d 53 58 34 4d 53 58 34 2d 2d 4d 46 5a 38 4d 46 5a 38 (MSX4MSX4--MFZ8MFZ8)
Magic header attribute: 4.0
Limit name/value/section/remark token to max size of 262143