PageLinkCheckerExtension.java
1.31 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.rewriter.linkchecker.LinkCheckerExtension
* com.day.cq.rewriter.linkchecker.LinkValidity
* com.day.cq.wcm.api.Page
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.resource.Resource
*/
package com.day.cq.wcm.core.impl;
import com.day.cq.rewriter.linkchecker.LinkCheckerExtension;
import com.day.cq.rewriter.linkchecker.LinkValidity;
import com.day.cq.wcm.api.Page;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.Resource;
@Component(metatype=0)
@Service(value={LinkCheckerExtension.class})
public class PageLinkCheckerExtension
implements LinkCheckerExtension {
public LinkValidity getLinkValidity(Resource resource) {
Page page = (Page)resource.adaptTo(Page.class);
if (page == null) {
return LinkValidity.VALID;
}
long tuv = page.timeUntilValid();
if (tuv == 0) {
return LinkValidity.VALID;
}
if (tuv == Long.MIN_VALUE) {
return LinkValidity.INVALID;
}
if (tuv < 0) {
return LinkValidity.EXPIRED;
}
return LinkValidity.PREDATED;
}
}