FvctxNodeImageProps.java
4.51 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.scene7.is.provider.catalog.Catalog
* com.scene7.is.provider.catalog.ObjectRecord
* com.scene7.is.sleng.ipp.IppBadImageAnchorException
* 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.provider.catalog.Catalog;
import com.scene7.is.provider.catalog.ObjectRecord;
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.FvctxImagePath;
import com.scene7.is.ps.provider.fvctx.FvctxImageProps;
import com.scene7.is.ps.provider.fvctx.FvctxImagePropsBuilder;
import com.scene7.is.ps.provider.fvctx.FvctxNode;
import com.scene7.is.ps.provider.fvctx.FvctxNodeNull;
import com.scene7.is.ps.provider.fvctx.FvctxRequestBuilder;
import com.scene7.is.ps.provider.fvctx.ImageInfo;
import com.scene7.is.sleng.ipp.IppBadImageAnchorException;
import com.scene7.is.util.error.ApplicationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class FvctxNodeImageProps
extends FvctxNodeNull {
@NotNull
private final FvctxRequestBuilder requestBuilder;
@NotNull
private final FvctxImagePropsBuilder imagePropsBuilder;
FvctxNodeImageProps(@NotNull FvctxRequestBuilder requestBuilder, @NotNull FvctxImagePropsBuilder imagePropsBuilder, @NotNull FvctxNode next) {
super(next);
this.requestBuilder = requestBuilder;
this.imagePropsBuilder = imagePropsBuilder;
}
@Override
public void startFrame(@NotNull String netPath, @NotNull String query, @NotNull Request parsedRequest, FvctxImageProps imageProps, boolean hasNestedFrame, boolean isMediaSetItem) throws ApplicationException {
ImageInfo imageInfo = this.buildImageInfo(netPath, query, parsedRequest);
this.getNext().startFrame(imageInfo.netPath, imageInfo.query, imageInfo.parsedRequest, imageInfo.imageProps, hasNestedFrame, isMediaSetItem);
}
@Override
public void image(@NotNull String netPath, @NotNull String query, @NotNull Request parsedRequest, FvctxImageProps imageProps) throws ApplicationException {
ImageInfo imageInfo = this.buildImageInfo(netPath, query, parsedRequest);
this.getNext().image(imageInfo.netPath, imageInfo.query, imageInfo.parsedRequest, imageInfo.imageProps);
}
@Override
public void swatch(@NotNull String netPath, @NotNull String query, @NotNull Request parsedRequest, FvctxImageProps imageProps, boolean hasNestedFrame, boolean isMediaItemSwatch) throws ApplicationException {
FvctxImageProps swatchProps = this.imagePropsBuilder.buildSwatchProps(parsedRequest, false);
this.getNext().swatch(netPath, query, parsedRequest, swatchProps, hasNestedFrame, isMediaItemSwatch);
}
@NotNull
private ImageInfo buildImageInfo(@NotNull String netPath, @NotNull String query, @NotNull Request parsedRequest) throws ApplicationException {
try {
FvctxImageProps props = this.imagePropsBuilder.buildImageProps(parsedRequest, false);
return new ImageInfo(netPath, query, parsedRequest, props);
}
catch (IppBadImageAnchorException e) {
Request defaultParsedRequest = this.getDefaultImageRequest(parsedRequest);
if (defaultParsedRequest != null) {
return this.buildDefaultImageInfo(defaultParsedRequest, (Throwable)e);
}
throw e;
}
}
@NotNull
private ImageInfo buildDefaultImageInfo(@NotNull Request defaultParsedRequest, @NotNull Throwable e) throws ApplicationException {
ModifierSet defaultAttr = defaultParsedRequest.getGlobalAttributes();
FvctxImageProps props = this.imagePropsBuilder.buildDefaultImageProps(defaultParsedRequest, false, e);
String defaultNetPath = defaultAttr.getOrDie(ModifierEnum.I_NET_PATH);
return new ImageInfo(defaultNetPath, "", defaultParsedRequest, props);
}
@Nullable
private Request getDefaultImageRequest(@NotNull Request parsedRequest) throws ApplicationException {
String defaultImagePath = parsedRequest.getDefaultImage();
if (defaultImagePath != null) {
defaultImagePath = FvctxImagePath.canonicalizeImagePath(parsedRequest.getRecord().getCatalog(), defaultImagePath);
return this.requestBuilder.buildRequest(defaultImagePath, "");
}
return null;
}
}