use of com.agiletec.plugins.jacms.aps.system.services.resource.model.AttachResource in project entando-core by entando.
the class ResourceManagerIntegrationTest method testLoadResource.
public void testLoadResource() throws Throwable {
try {
ResourceInterface resource = this._resourceManager.loadResource("44");
assertTrue(resource instanceof ImageResource);
assertTrue(resource.isMultiInstance());
assertEquals(resource.getDescription(), "logo");
assertEquals(resource.getCategories().size(), 1);
resource = this._resourceManager.loadResource("7");
assertTrue(resource instanceof AttachResource);
assertFalse(resource.isMultiInstance());
assertEquals(resource.getDescription(), "configurazione");
assertEquals(resource.getCategories().size(), 0);
} catch (Throwable t) {
throw t;
}
}
use of com.agiletec.plugins.jacms.aps.system.services.resource.model.AttachResource in project entando-core by entando.
the class AttachAttribute method getIndexeableFieldValue.
@Override
public String getIndexeableFieldValue() {
StringBuilder buffer = new StringBuilder();
if (null != super.getIndexeableFieldValue()) {
buffer.append(super.getIndexeableFieldValue());
}
String extraValue = null;
ResourceInterface resource = this.getResource();
if (resource != null) {
InputStream is = ((AttachResource) resource).getResourceStream();
if (null != is) {
AutoDetectParser parser = new AutoDetectParser();
BodyContentHandler handler = new BodyContentHandler(-1);
Metadata metadata = new Metadata();
try {
parser.parse(is, handler, metadata);
extraValue = handler.toString();
} catch (Throwable t) {
_logger.error("Error while processing the parsing", t);
} finally {
try {
is.close();
} catch (IOException ex) {
_logger.error("Error closing stream", ex);
}
}
}
}
if (null != extraValue) {
buffer.append(" ").append(extraValue);
}
return buffer.toString();
}
Aggregations