FvctxPipelineProcessor.java
7.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.scene7.is.catalog.util.localization.LocaleMap
* com.scene7.is.catalog.util.localization.LocalizedText
* com.scene7.is.provider.ImageSet
* com.scene7.is.provider.ImageSetColorLabel
* com.scene7.is.provider.ImageSetItem
* com.scene7.is.sleng.Color
* com.scene7.is.util.SizeInt
* com.scene7.is.util.UrlRequest
* com.scene7.is.util.error.ApplicationException
* org.jetbrains.annotations.NotNull
* org.jetbrains.annotations.Nullable
*/
package com.scene7.is.ps.provider.fvctx;
import com.scene7.is.catalog.util.localization.LocaleMap;
import com.scene7.is.catalog.util.localization.LocalizedText;
import com.scene7.is.provider.ImageSet;
import com.scene7.is.provider.ImageSetColorLabel;
import com.scene7.is.provider.ImageSetItem;
import com.scene7.is.ps.provider.IZoomException;
import com.scene7.is.ps.provider.ModifierSet;
import com.scene7.is.ps.provider.Request;
import com.scene7.is.ps.provider.defs.ModifierEnum;
import com.scene7.is.ps.provider.fvctx.FvctxImageProps;
import com.scene7.is.ps.provider.fvctx.FvctxNode;
import com.scene7.is.ps.provider.fvctx.FvctxUtil;
import com.scene7.is.ps.provider.fvctx.MediaSetMetaData;
import com.scene7.is.sleng.Color;
import com.scene7.is.util.SizeInt;
import com.scene7.is.util.UrlRequest;
import com.scene7.is.util.error.ApplicationException;
import java.util.List;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class FvctxPipelineProcessor {
public static void processSingleImageRequest(@NotNull Request request, @NotNull FvctxNode pipeline) throws IZoomException {
try {
ModifierSet attr = request.getGlobalAttributes();
String netPath = attr.getOrDie(ModifierEnum.I_NET_PATH);
pipeline.startFrameset();
pipeline.startFrame(netPath, "", request, null, false, false);
pipeline.endFrame(null, "", MediaSetMetaData.EMPTY_MEDIA_SET_META_DATA, false);
pipeline.endFrameset(null, null, null, false);
}
catch (IZoomException e) {
throw e;
}
catch (ApplicationException e) {
throw new IZoomException(IZoomException.FVCTX_IMAGE_ERROR, e.getMessage(), (Throwable)e);
}
}
public static void processImageSet(@NotNull ImageSet imageSet, @NotNull FvctxNode pipeline) throws IZoomException {
if (imageSet.items.isEmpty()) {
return;
}
if (((ImageSetItem)imageSet.items.get((int)0)).separator != ',') {
throw new IZoomException(IZoomException.FVCTX_NO_FRAME_AT_START_IMAGESET, imageSet.generateString());
}
pipeline.startFrameset();
boolean lastSwatchEmpty = false;
int i = 0;
for (ImageSetItem item : imageSet.items) {
switch (item.separator) {
case ',': {
FvctxPipelineProcessor.processFrame(i, item, pipeline);
lastSwatchEmpty = false;
break;
}
case ':': {
FvctxPipelineProcessor.processImage(item, pipeline);
lastSwatchEmpty = false;
break;
}
case ';': {
lastSwatchEmpty = FvctxPipelineProcessor.processSwatch(lastSwatchEmpty, item, pipeline);
break;
}
default: {
throw new IZoomException(IZoomException.FVCTX_INVALID_SEPARATOR, FvctxPipelineProcessor.errorMessage(item));
}
}
++i;
}
pipeline.endFrame(null, "", MediaSetMetaData.EMPTY_MEDIA_SET_META_DATA, false);
pipeline.endFrameset(null, null, null, false);
}
private FvctxPipelineProcessor() {
}
private static void processFrame(int i, @NotNull ImageSetItem item, @NotNull FvctxNode pipeline) throws IZoomException {
try {
if (i > 0) {
pipeline.endFrame(null, "", MediaSetMetaData.EMPTY_MEDIA_SET_META_DATA, false);
}
if (item.asset == null || item.asset.isEmpty()) {
throw new IZoomException(IZoomException.FVCTX_IMAGE_EXPECTED, item.generateString(), null);
}
if (FvctxUtil.hasBraces(item.asset)) {
pipeline.startFrame(item.asset, "", null, null, false, false);
} else {
UrlRequest request = UrlRequest.splitUrlRequest((String)item.asset);
pipeline.startFrame(request.path, request.query, null, null, false, false);
}
}
catch (IZoomException e) {
throw e;
}
catch (ApplicationException e) {
throw new IZoomException(IZoomException.FVCTX_FRAME_ERROR, FvctxPipelineProcessor.errorMessage(item), (Throwable)e);
}
}
private static void processImage(@NotNull ImageSetItem item, @NotNull FvctxNode pipeline) throws IZoomException {
try {
UrlRequest request = FvctxPipelineProcessor.processImageAsset(item);
if (request != null) {
pipeline.image(request.path, request.query, null, null);
}
}
catch (IZoomException e) {
throw e;
}
catch (ApplicationException e) {
throw new IZoomException(IZoomException.FVCTX_IMAGE_ERROR, FvctxPipelineProcessor.errorMessage(item), (Throwable)e);
}
}
private static boolean processSwatch(boolean lastSwatchEmpty, @NotNull ImageSetItem item, @NotNull FvctxNode pipeline) throws IZoomException {
try {
if (lastSwatchEmpty) {
pipeline.defaultSwatch();
}
if (item.colorLabel != null) {
pipeline.swatch(new ImageSetColorLabel(item.colorLabel.color, item.colorLabel.label.urlDecode()), LocaleMap.EMPTY_LOCALE_MAP, "", false);
return false;
}
UrlRequest request = FvctxPipelineProcessor.processImageAsset(item);
if (request != null) {
pipeline.swatch(request.path, request.query, null, null, false, false);
return false;
}
return true;
}
catch (IZoomException e) {
throw e;
}
catch (ApplicationException e) {
throw new IZoomException(IZoomException.FVCTX_SWATCH_ERROR, FvctxPipelineProcessor.errorMessage(item), (Throwable)e);
}
catch (IllegalArgumentException e) {
throw new IZoomException(IZoomException.FVCTX_INVALID_COLOR_LABEL, FvctxPipelineProcessor.errorMessage(item), e);
}
}
@Nullable
private static UrlRequest processImageAsset(@NotNull ImageSetItem item) throws IZoomException {
if (item.asset == null) {
throw new IZoomException(IZoomException.FVCTX_IMAGE_EXPECTED, item.generateString(), null);
}
if (item.asset.isEmpty()) {
return null;
}
return UrlRequest.splitUrlRequest((String)item.asset);
}
@NotNull
private static String errorMessage(@NotNull ImageSetItem item) {
return item.generateString();
}
}