method2testcases
stringlengths
118
6.63k
### Question: SensorInstanceProvider implements InsertSensorOfferingListener { public SensorConfigurationRepository getSensorConfigurationRepository() { return sensorConfigurationRepository; } void init(); Iterable<SensorPlugin> getSensors(); boolean containsTaskWith(String taskId); SensorTask getTaskForTaskId(String ...
### Question: XmlValidationDelegate implements RequestDelegationHandler { protected void validateRequiredVersionParameter(XmlObject requestDocument) throws OwsException { XmlCursor xmlCursor = requestDocument.newCursor(); xmlCursor.toFirstChild(); if (moveToAttribute(xmlCursor, "version")) { service.validateVersionPara...
### Question: SensorInstanceProvider implements InsertSensorOfferingListener { public void setSensorConfigurationRepository(SensorConfigurationRepository sensorConfigurationRepository) throws InternalServiceException { this.sensorConfigurationRepository = sensorConfigurationRepository; } void init(); Iterable<SensorPl...
### Question: SensorInstanceProvider implements InsertSensorOfferingListener { public SensorTaskRepository getSensorTaskRepository() { return sensorTaskRepository; } void init(); Iterable<SensorPlugin> getSensors(); boolean containsTaskWith(String taskId); SensorTask getTaskForTaskId(String taskId); boolean containsSe...
### Question: SensorInstanceProvider implements InsertSensorOfferingListener { public void setSensorTaskRepository(SensorTaskRepository sensorTaskRepository) { this.sensorTaskRepository = sensorTaskRepository; } void init(); Iterable<SensorPlugin> getSensors(); boolean containsTaskWith(String taskId); SensorTask getTa...
### Question: SensorInstanceProvider implements InsertSensorOfferingListener { public void handleInsertSensorOffering(InsertSensorOfferingEvent insertSensorOfferingEvent) throws InternalServiceException { InsertSensorOfferingDocument insertSensorOfferingDocument = insertSensorOfferingEvent.getInsertSensorOffering(); In...
### Question: SpsOperator { protected SensorTask getSensorTask(String sensorTaskId) throws OwsException { if (!sensorInstanceProvider.containsTaskWith(sensorTaskId)) { handleInvalidParameter("task", sensorTaskId); } return sensorInstanceProvider.getTaskForTaskId(sensorTaskId); } SensorPlugin getSensorInstance(String p...
### Question: SpsOperator { public SensorPlugin getSensorInstance(String procedure) throws OwsException { if (!sensorInstanceProvider.containsSensorWith(procedure)) { handleInvalidParameter("procedure", procedure); } SensorPlugin sensorPlugin = sensorInstanceProvider.getSensorForProcedure(procedure); return NonBlocking...
### Question: XmlValidationDelegate implements RequestDelegationHandler { protected boolean isGetCapabilitiesRequest(XmlObject request) { XmlCursor xmlCursor = request.newCursor(); xmlCursor.toFirstChild(); String operationName = xmlCursor.getName().getLocalPart(); return operationName.equalsIgnoreCase("GetCapabilities...
### Question: XmlValidationDelegate implements RequestDelegationHandler { protected void assureCorrectServiceAndVersionRequestParameters(XmlObject request) throws OwsException { if (!isGetCapabilitiesRequest(request)) { validateRequiredServiceParameter(request); validateRequiredVersionParameter(request); } else { servi...
### Question: SensorTask { public String getTaskStatusAsString() { return taskStatus != null ? taskStatus.toString() : null; } SensorTask(); SensorTask(String taskId, String procedure); String getTaskId(); Calendar getCalendarInstance(); void setUpdateTime(Calendar calendar); Calendar getUpdateTime(); String getFormat...
### Question: StatusReportGenerator { public static StatusReportGenerator createFor(SensorTask sensorTask) { return new StatusReportGenerator(sensorTask); } private StatusReportGenerator(SensorTask sensorTask); static StatusReportGenerator createFor(SensorTask sensorTask); StatusReportType generateWithTaskingParameter...
### Question: DynamicClassFactory { private Class<?> createClass(ClassPair classPair) { String className = generateClassName(classPair); String classStr = className.replaceAll("\\.", "/"); String keyClassType = Type.getDescriptor(classPair.keyClass); String valueClassType = Type.getDescriptor(classPair.valueClass); Cla...
### Question: EnvironmentVariableConfigurationSource extends AbstractConfigurationSource { public EnvironmentVariableConfigurationSource(final int priority) { super(priority, "EnvironmentVariable"); } EnvironmentVariableConfigurationSource(final int priority); @Override Configuration configuration(); }### Answer: @Tes...
### Question: EnvironmentVariableConfigurationSource extends AbstractConfigurationSource { @Override public Configuration configuration() { return _configuration; } EnvironmentVariableConfigurationSource(final int priority); @Override Configuration configuration(); }### Answer: @Test public void testConfiguration() { ...
### Question: DefaultProperty implements Property { @Override public String value() { return manager().getPropertyValue(key()); } DefaultProperty(ConfigurationManager manager, String key); @Override String key(); @Override String value(); @Override String toString(); }### Answer: @Test public void test() { MyConfigura...
### Question: DefaultCachedProperty extends PropertyWrapper implements CachedProperty { @Override public String value() { return _value; } DefaultCachedProperty(Property property); @Override String value(); @Override void refresh(); }### Answer: @Test public void testValue() { MyProperty mp = new MyProperty("k1", "v1"...
### Question: DefaultCachedProperty extends PropertyWrapper implements CachedProperty { @Override public void refresh() { String before = value(); _value = super.value(); if (Objects.equal(before, _value)) return; if (_disableRefreshLog) return; _logger.info( String.format("Default cached property has been refreshed, k...
### Question: DefaultValues { public static boolean isDefault(Object value) { if (value == null) return true; if (value instanceof Number && ((Number)value).doubleValue() == 0.0) return true; return false; } private DefaultValues(); static boolean isDefault(Object value); }### Answer: @Test public void isDefaultTest(...
### Question: StringValues { public static String toString(Object value) { if (value == null) return null; return value.toString(); } private StringValues(); static String toString(Object value); static String toLowerCase(String value); static String toUpperCase(String value); static boolean isNullOrWhitespace(String ...
### Question: PatternCorrector implements ValueCorrector<String> { @Override public String correct(String value) { if (Strings.isNullOrEmpty(value)) return null; Matcher matcher = _pattern.matcher(value); if (matcher.matches()) return value; else return null; } PatternCorrector(Pattern pattern); @Override String correc...
### Question: ServletContextConfigurationSource extends AbstractConfigurationSource { @Override public Configuration configuration() { return _configuration; } ServletContextConfigurationSource(final int priority, final ServletContext context); @Override Configuration configuration(); }### Answer: @Test public void te...
### Question: DefaultConfigurationManager implements ConfigurationManager { protected void init(List<ConfigurationSource> sources) { if (CollectionValues.isNullOrEmpty(sources)) { _sources = EMPTY_CONFIGURATION_SOURCE_LIST; _logger.warn("sources is null or empty"); return; } _sources = new ArrayList<ConfigurationSource...
### Question: ServletContextConfiguration implements Configuration { @Override public String getPropertyValue(String key) { if (StringValues.isNullOrWhitespace(key)) { _logger.warn("ServletContext key is null or empty!"); return null; } String value = _context.getInitParameter(key); return value; } ServletContextConfig...
### Question: DefaultLoadBalancer implements LoadBalancer { @Override public LoadBalancerRequestContext getRequestContext(LoadBalancerRequestConfig loadBalancerRequestConfig) { LoadBalancerRoute route = _loadBalancerContext.serverSourceFilter().getLoadBalancerRoute(loadBalancerRequestConfig); if (route == null) { LogUt...
### Question: RoundRobinRule implements LoadBalancerRule { public RoundRobinRule() { serverContexts = new ConcurrentHashMap<>(); roundRobinAlgorithm = new DefaultRoundRobinAlgorithm<>(); } RoundRobinRule(); @Override String getRuleId(); @Override String getDescription(); @Override Server choose(final LoadBalancerRoute ...
### Question: SSJsonSerializer implements StreamSerializer, StringSerializer { @Override public <T> T deserialize(InputStream is, Class<T> clazz) { try { return _mapper.readValue(is, clazz); } catch (RuntimeException | Error ex) { throw ex; } catch (Exception ex) { throw new SerializationException(ex); } } SSJsonSerial...
### Question: UnsafeIDGenerator { public static String timeBasedRandom(int length) { String date = DateValues.toString(new Date(), TIME_FORMAT, UTC_TIME_ZONE); if (length < TIME_BASED_RANDOM_MIN_LENGTH) length = TIME_BASED_RANDOM_MIN_LENGTH; return date + random(length - TIME_FORMAT.length()); } private UnsafeIDGenera...
### Question: DefaultValueConfigurationSource extends AbstractConfigurationSource { public DefaultValueConfigurationSource(Map<String, String> keyValueMap) { super(Integer.MIN_VALUE, "DefaultValue"); _defaultValueConfiguration = new DefaultValueConfiguration(keyValueMap); } DefaultValueConfigurationSource(Map<String, S...
### Question: EnvironmentVariableConfiguration implements Configuration { @Override public String getPropertyValue(String key) { if (Strings.isNullOrEmpty(key)) { _logger.warn("ENV key is null or empty!"); return null; } String value = System.getProperty(key); return value; } @Override String getPropertyValue(String k...
### Question: QueryResultDataPoint { public long getTimestamp() { return timestamp; } QueryResultDataPoint(); QueryResultDataPoint(long timestamp, double value); long getTimestamp(); void setTimestamp(long timestamp); double getValue(); void setValue(double value); @Override boolean equals(Object o); @Override int has...
### Question: Utils { public static Map<String, Object> makeError(String errorMessage, String errorCause, String errorPart) { Map<String, Object> error = new HashMap<>(); error.put(ERROR_MESSAGE, errorMessage); error.put(ERROR_CAUSE, errorCause); error.put(ERROR_PART, errorPart); return error; } private Utils(); stati...
### Question: Utils { public static Response getErrorResponse(String id, int status, String message, String context) { ErrorResponse errorResponse = new ErrorResponse(); errorResponse.id = id; errorResponse.errorSource = context; errorResponse.errorMessage = message; String jsonErrorResponse = jsonStringFromObject(erro...
### Question: Utils { public static String createUuid() { return UUID.randomUUID().toString(); } private Utils(); static Map<String, Object> makeError(String errorMessage, String errorCause, String errorPart); static Response getErrorResponse(String id, int status, String me...
### Question: Utils { public static long parseDuration(String v) { int idx; char last; if ((idx = v.indexOf('-')) > 0) { idx -= 1; last = v.charAt(idx); } else { idx = v.length() - 1; last = v.charAt(idx); } long period = 0; try { period = Long.parseLong(v.substring(0, idx)); } catch (NumberFormatException e) { return ...
### Question: MetricResources { Optional<Map<String, List<String>>> getTags(Map<String, List<String>> tags) { if (configuration.isAuthEnabled()) { if (tags == null) { tags = Maps.newHashMap(); } String tenantId = getTenantId(); tags.put("zenoss_tenant_id", Lists.newArrayList(tenantId)); } return Optional.fromNullable(t...
### Question: MetricService implements MetricServiceAPI { public static List<MetricSpecification> metricFilter(List<? extends MetricSpecification> list) { List<MetricSpecification> result = new ArrayList<>(); if (list != null) { for (MetricSpecification spec : list) { if (spec.getMetric() != null) { result.add(spec); }...
### Question: MetricService implements MetricServiceAPI { @Override public Response query(Optional<String> id, Optional<String> start, Optional<String> end, Optional<ReturnSet> returnset, Optional<Boolean> series, Optional<String> downsample, double downsampleMultiplier, Optional<Map<String, List<String>>> tags, List<M...
### Question: MetricService implements MetricServiceAPI { @Override public Response options(String request) { corsHeaders = request; return makeCORS(Response.ok(), request); } MetricService(); static List<MetricSpecification> metricFilter(List<? extends MetricSpecification> list); static List<MetricSpecification> calcu...
### Question: QueryResultDataPoint { public void setTimestamp(long timestamp) { this.timestamp = timestamp; } QueryResultDataPoint(); QueryResultDataPoint(long timestamp, double value); long getTimestamp(); void setTimestamp(long timestamp); double getValue(); void setValue(double value); @Override boolean equals(Obje...
### Question: MetricKey implements IHasShortcut { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; MetricKey metricKey = (MetricKey) o; if (metric != null ? !metric.equals(metricKey.metric) : metricKey.metric != null) return false; if (na...
### Question: MetricKey implements IHasShortcut { @JsonProperty("metric") public String getMetric() { return metric; } @JsonProperty("id") String getId(); @JsonProperty("metric") String getMetric(); @JsonProperty("tags") Tags getTags(); @JsonProperty("name") String getName(); @Override boolean equals(Object o); @Overr...
### Question: MetricKey implements IHasShortcut { @JsonProperty("tags") public Tags getTags() { return tags; } @JsonProperty("id") String getId(); @JsonProperty("metric") String getMetric(); @JsonProperty("tags") Tags getTags(); @JsonProperty("name") String getName(); @Override boolean equals(Object o); @Override int ...
### Question: MetricKey implements IHasShortcut { @JsonProperty("name") public String getName() { return name; } @JsonProperty("id") String getId(); @JsonProperty("metric") String getMetric(); @JsonProperty("tags") Tags getTags(); @JsonProperty("name") String getName(); @Override boolean equals(Object o); @Override in...
### Question: MetricKey implements IHasShortcut { public static MetricKey fromValue(MetricSpecification spec) { MetricKey key = new MetricKey(); key.metric = spec.getMetricOrName(); key.name = spec.getNameOrMetric(); key.id = spec.getId(); if (spec.getTags() != null && spec.getTags().size() > 0) { key.tags = Tags.fromV...
### Question: MetricKey implements IHasShortcut { public String toString() { return String.format("MetricKey=[metric=%s, name=%s, tags=%s, id=%s]", metric, name, tags, id); } @JsonProperty("id") String getId(); @JsonProperty("metric") String getMetric(); @JsonProperty("tags") Tags getTags(); @JsonProperty("name") Stri...
### Question: DefaultResultProcessor implements ResultProcessor, ReferenceProvider { @Override public double lookup(String name, Closure closure) throws UnknownReferenceException { if (null == closure) { throw new NullPointerException("null closure passed to lookup() method."); } if ("time".equalsIgnoreCase(nam...
### Question: DefaultResultProcessor implements ResultProcessor, ReferenceProvider { @Override public Buckets<IHasShortcut> processResults() throws IOException, ClassNotFoundException, BadExpressionException { initialize(); for (MetricSpecification metricSpecification : queries) { preProcessQuerySpecifications(...
### Question: QueryResultDataPoint { public double getValue() { return value; } QueryResultDataPoint(); QueryResultDataPoint(long timestamp, double value); long getTimestamp(); void setTimestamp(long timestamp); double getValue(); void setValue(double value); @Override boolean equals(Object o); @Override int hashCode(...
### Question: OpenTSDBQueryResult { @JsonIgnore public SortedMap<Long, Double> getDataPoints() { if (null == dps) { dps = new TreeMap<>(); } return dps; } QueryStatus getStatus(); void setStatus(QueryStatus status); String debugString(); void addTags(Map<String, List<String>> tagsToAdd); void addDataPoint(long i, doub...
### Question: NewValue { public double getMean() { return (numDataValues > 0) ? newMean : Double.NaN; } void clear(); void push(double x); long getNumDataValues(); double getMean(); double getVariance(); double getStandardDeviation(); double getSum(); }### Answer: @Test public void testGetMean() { NewValue victim = n...
### Question: NewValue { public double getSum() { return sum; } void clear(); void push(double x); long getNumDataValues(); double getMean(); double getVariance(); double getStandardDeviation(); double getSum(); }### Answer: @Test public void testGetSum() throws Exception { NewValue victim = new NewValue(); Double[] ...
### Question: NewValue { public double getVariance() { return ((numDataValues > 1) ? newS /(numDataValues - 1) : Double.NaN); } void clear(); void push(double x); long getNumDataValues(); double getMean(); double getVariance(); double getStandardDeviation(); double getSum(); }### Answer: @Test public void testGetVari...
### Question: Buckets { public final void add(final P primaryKey, final long timestamp, final double value) { long ts = getBucketTimestamp(timestamp); Bucket b = bucketList.get(ts); if (b == null) { b = new Bucket(); bucketList.put(ts, b); } b.add(primaryKey, value); } Buckets(); Buckets(final long secondsPerBucket); ...
### Question: Buckets { public final Buckets<P>.Bucket getBucket(long timestamp) { long bucketTimestamp = getBucketTimestamp(timestamp); return bucketList.get(bucketTimestamp); } Buckets(); Buckets(final long secondsPerBucket); Map<Long, Bucket> getBucketList(); void addQueryStatus(P key, QueryStatus status); QuerySta...
### Question: Buckets { public final SortedSet<Long> getTimestamps() { SortedSet<Long> result = new TreeSet<>(bucketList.keySet()); return result; } Buckets(); Buckets(final long secondsPerBucket); Map<Long, Bucket> getBucketList(); void addQueryStatus(P key, QueryStatus status); QueryStatus getQueryStatus(P key); fin...
### Question: QueryResultDataPoint { public void setValue(double value) { this.value = value; } QueryResultDataPoint(); QueryResultDataPoint(long timestamp, double value); long getTimestamp(); void setTimestamp(long timestamp); double getValue(); void setValue(double value); @Override boolean equals(Object o); @Overri...
### Question: Buckets { public final long getSecondsPerBucket() { return secondsPerBucket; } Buckets(); Buckets(final long secondsPerBucket); Map<Long, Bucket> getBucketList(); void addQueryStatus(P key, QueryStatus status); QueryStatus getQueryStatus(P key); final void add(final P primaryKey, final long timestamp, fi...
### Question: Buckets { public final void dump(PrintStream ps) { List<Long> keys = new ArrayList<>(bucketList.keySet()); Collections.sort(keys); for (long k : keys) { ps.format("BUCKET: %d (%d) (%s)%n", k, k * secondsPerBucket, new Date(k * secondsPerBucket * 1000)); for (P key : bucketList.get(k).values.keySet()) { Va...
### Question: Value { public final double getValue() { if (count != 0) { return sum / (double) count; } if (hasInterpolated) { return interpolated; } return Double.NaN; } final double getValue(); final double getSum(); final long getCount(); final void add(final double value); final void addInterpolated(final double v...
### Question: Value { public final double getSum() { return sum; } final double getValue(); final double getSum(); final long getCount(); final void add(final double value); final void addInterpolated(final double value); final boolean valueIsInterpolated(); final void remove(final double value); }### Answer: @Test p...
### Question: QueryStatus { @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; QueryStatus that = (QueryStatus) o; if (message != null ? !message.equals(that.message) : that.message != null) return false; if (status != that.status) return f...
### Question: Value { public final long getCount() { return count; } final double getValue(); final double getSum(); final long getCount(); final void add(final double value); final void addInterpolated(final double value); final boolean valueIsInterpolated(); final void remove(final double value); }### Answer: @Test...
### Question: Value { public final void add(final double value) { sum += value; count++; } final double getValue(); final double getSum(); final long getCount(); final void add(final double value); final void addInterpolated(final double value); final boolean valueIsInterpolated(); final void remove(final double value...
### Question: Value { public final boolean valueIsInterpolated() { return count == 0 && hasInterpolated; } final double getValue(); final double getSum(); final long getCount(); final void add(final double value); final void addInterpolated(final double value); final boolean valueIsInterpolated(); final void remove(fi...
### Question: Value { public final void remove(final double value) { sum -= value; count--; } final double getValue(); final double getSum(); final long getCount(); final void add(final double value); final void addInterpolated(final double value); final boolean valueIsInterpolated(); final void remove(final double va...
### Question: QueryStatus { @Override public int hashCode() { int result = message != null ? message.hashCode() : 0; result = 31 * result + (status != null ? status.hashCode() : 0); return result; } QueryStatus(); QueryStatus(QueryStatusEnum status, String message); @Override boolean equals(Object o); @Override int ha...
### Question: QueryStatus { public QueryStatusEnum getStatus() { return status; } QueryStatus(); QueryStatus(QueryStatusEnum status, String message); @Override boolean equals(Object o); @Override int hashCode(); QueryStatusEnum getStatus(); void setStatus(QueryStatusEnum status); String getMessage(); void setMessage(S...
### Question: QueryStatus { public void setStatus(QueryStatusEnum status) { this.status = status; } QueryStatus(); QueryStatus(QueryStatusEnum status, String message); @Override boolean equals(Object o); @Override int hashCode(); QueryStatusEnum getStatus(); void setStatus(QueryStatusEnum status); String getMessage();...
### Question: QueryStatus { public String getMessage() { return message; } QueryStatus(); QueryStatus(QueryStatusEnum status, String message); @Override boolean equals(Object o); @Override int hashCode(); QueryStatusEnum getStatus(); void setStatus(QueryStatusEnum status); String getMessage(); void setMessage(String m...
### Question: QueryStatus { public void setMessage(String message) { this.message = message; } QueryStatus(); QueryStatus(QueryStatusEnum status, String message); @Override boolean equals(Object o); @Override int hashCode(); QueryStatusEnum getStatus(); void setStatus(QueryStatusEnum status); String getMessage(); void...
### Question: MboxIterator implements Iterable<CharBufferWrapper>, Closeable { public Iterator<CharBufferWrapper> iterator() { return new MessageIterator(); } private MboxIterator(final File mbox, final Charset charset, final String regexpPattern, ...
### Question: Mapping { String getResourceType(String nodePath, String nodeType) { String result = null; if(path!=null && nodePath.startsWith(path) && nodeTypeMatches(nodeType)) { final String [] paths = nodePath.split("/"); if(paths.length >= resourceTypeIndex+1) { result = paths[resourceTypeIndex]; } } return result;...
### Question: ThreadKeyGeneratorImpl implements ThreadKeyGenerator { public String getThreadKey(String subject) { String wordCharsSubj; String noReSubj; if (subject != null) { noReSubj = removeRe(subject); wordCharsSubj = noReSubj.replaceAll("\\W", "_"); if (!isAddressable(wordCharsSubj)) { noReSubj = wordCharsSubj = U...
### Question: Mime4jMboxParserImpl implements MboxParser { @Override public Iterator<Message> parse(InputStream is) throws IOException { return new Mime4jParserIterator(is); } @Override Iterator<Message> parse(InputStream is); }### Answer: @Test public void testMboxParsing() throws IOException { Iterator<Message> ite...
### Question: SlingshotUtil { public static String getUserId(final Resource resource) { final String prefix = SlingshotConstants.APP_ROOT_PATH + "/"; String id = null; if ( resource.getPath().startsWith(prefix) ) { final int areaEnd = resource.getPath().indexOf('/', prefix.length()); if ( areaEnd != -1 ) { final int us...
### Question: SlingshotUtil { public static String getContentPath(final Resource resource) { final String prefix = SlingshotConstants.APP_ROOT_PATH + "/users/" + getUserId(resource) + "/"; final String path = resource.getPath(); if ( path != null && path.startsWith(prefix) ) { return path.substring(prefix.length() - 1)...
### Question: Util { public static String filter(final String rsrcname) { final StringBuilder sb = new StringBuilder(); char lastAdded = 0; final String name = rsrcname.toLowerCase(); for(int i=0; i < name.length(); i++) { final char c = name.charAt(i); char toAdd = c; if (ALLOWED_CHARS.indexOf(c) < 0) { if (lastAdded ...
### Question: EditorLinksImpl extends AbstractEmptyTextComponent implements EditorLinks { @Override public String getAssetDetailsEditorPath() { return request.getResourceResolver().map(ASSET_DETAILS_PREFIX + asset.getPath()); } @Override String getAssetDetailsEditorPath(); @Override String getAssetFolderEditorPath(); ...
### Question: ExternalRedirectRenditionDispatcherImpl extends AbstractRenditionDispatcherImpl implements AssetRenditionDispatcher { @Override public String getLabel() { return cfg.label(); } @Override String getLabel(); @Override String getName(); @Override Map<String, String> getOptions(); @Override boolean isHidden(...
### Question: ExternalRedirectRenditionDispatcherImpl extends AbstractRenditionDispatcherImpl implements AssetRenditionDispatcher { @Override public String getName() { return cfg.name(); } @Override String getLabel(); @Override String getName(); @Override Map<String, String> getOptions(); @Override boolean isHidden();...
### Question: ExternalRedirectRenditionDispatcherImpl extends AbstractRenditionDispatcherImpl implements AssetRenditionDispatcher { @Override public Map<String, String> getOptions() { return assetRenditions.getOptions(mappings); } @Override String getLabel(); @Override String getName(); @Override Map<String, String> g...
### Question: ExternalRedirectRenditionDispatcherImpl extends AbstractRenditionDispatcherImpl implements AssetRenditionDispatcher { @Override public Set<String> getRenditionNames() { if (mappings == null) { return Collections.EMPTY_SET; } else { return mappings.keySet(); } } @Override String getLabel(); @Override Stri...
### Question: ExternalRedirectRenditionDispatcherImpl extends AbstractRenditionDispatcherImpl implements AssetRenditionDispatcher { @Override public void dispatch(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException, ServletException { final AssetRenditionParameters parameters = new As...
### Question: AssetRenditionServlet extends SlingSafeMethodsServlet { public final void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws IOException, ServletException { try { final AssetRenditionParameters parameters = new AssetRenditionParameters(request); if (acceptsAssetRenditionParam...
### Question: AssetRenditionServlet extends SlingSafeMethodsServlet { protected void setResponseHeaders(final SlingHttpServletResponse response, final AssetRenditionParameters parameters) { if (parameters.isDownload()) { response.setHeader("Content-Disposition", String.format("attachment; filename=%s", parameters.getFi...
### Question: AssetRenditionsZipperImpl implements AssetRenditionsDownloadOrchestrator { @Override public boolean accepts(SlingHttpServletRequest request, List<AssetModel> assets, List<String> renditionNames) { return NAME.equals(request.getRequestParameter(REQUEST_PARAMETER_NAME).getString()); } @Override void execut...
### Question: MetadataImpl extends AbstractEmptyTextComponent implements Metadata { @Override public String getFormat() { if (type == null) { getType(); } switch (type) { case DATE: return formatDate; case NUMBER: return formatNumber; default: return null; } } @PostConstruct void init(); @Override DataType getType(); ...
### Question: AssetRenditionsZipperImpl implements AssetRenditionsDownloadOrchestrator { protected String getFileName(final ValueMap properties) { String fileName = properties.get(PN_FILE_NAME, StringUtils.defaultString(cfg.file_name(), DEFAULT_FILE_ATTACHMENT_NAME)); if (!StringUtils.endsWith(fileName, ZIP_EXTENSION))...
### Question: AssetRenditionsZipperImpl implements AssetRenditionsDownloadOrchestrator { protected void checkForMaxSize(long size) throws AssetRenditionsException { if (cfg.max_size() >= 0 && size > cfg.max_size() * BYTES_IN_MB) { throw new AssetRenditionsException("Selected assets exceed maximum allows size."); } } @...
### Question: AssetRenditionsZipperImpl implements AssetRenditionsDownloadOrchestrator { protected String getZipEntryName(final String folderName, final AssetModel asset, final String renditionName, final String responseContentType, final Set<String> zipEntryFileNames) { final String extension = mimeTypeService.getExte...
### Question: AssetRenditionsDownloadServlet extends SlingAllMethodsServlet implements AssetRenditionsDownloadOrchestratorManager { protected List<AssetModel> getAssets(final SlingHttpServletRequest request) { final RequestParameter[] requestParameters = request.getRequestParameters(REQ_KEY_ASSET_PATHS); if (requestPar...
### Question: AssetRenditionsDownloadServlet extends SlingAllMethodsServlet implements AssetRenditionsDownloadOrchestratorManager { protected List<String> getRenditionNames(final SlingHttpServletRequest request) { final String[] allowedRenditionNames = request.getResource().getValueMap().get(PN_ALLOWED_RENDITION_NAMES,...
### Question: AssetRenditionsDownloadServlet extends SlingAllMethodsServlet implements AssetRenditionsDownloadOrchestratorManager { @Override protected final void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { servletHelper.addSlingBindings(request, res...
### Question: AssetRenditionDownloadResponse extends BufferedSlingHttpServletResponse { public ByteArrayOutputStream getByteArrayOutputStream() { return this.baos; } AssetRenditionDownloadResponse(SlingHttpServletResponse wrappedResponse, StringWriter writer, ByteArrayOutputStream outputStream); boolean isRedirect(); S...
### Question: AssetRenditionDownloadResponse extends BufferedSlingHttpServletResponse { @Override public String getContentType() { return StringUtils.defaultIfEmpty(contentType, super.getContentType()); } AssetRenditionDownloadResponse(SlingHttpServletResponse wrappedResponse, StringWriter writer, ByteArrayOutputStream...
### Question: AssetRenditionDownloadRequest extends SlingHttpServletRequestWrapper { @Override public Object getAttribute(String name) { if (SlingBindings.class.getName().equals(name)) { return bindings; } else { return super.getAttribute(name); } } AssetRenditionDownloadRequest(final SlingHttpServletRequest wrappedReq...
### Question: AssetRenditionDownloadRequest extends SlingHttpServletRequestWrapper { @Override public Resource getResource() { return resource; } AssetRenditionDownloadRequest(final SlingHttpServletRequest wrappedRequest, final String method, ...
### Question: AssetRenditionDownloadRequest extends SlingHttpServletRequestWrapper { @Override public String getMethod() { return method; } AssetRenditionDownloadRequest(final SlingHttpServletRequest wrappedRequest, final String method, f...
### Question: AssetRenditionDownloadRequest extends SlingHttpServletRequestWrapper { @Override public RequestPathInfo getRequestPathInfo() { return new RequestPathInfo() { @Nonnull @Override public String getResourcePath() { return getResource().getPath(); } @CheckForNull @Override public String getExtension() { return...