Search in sources :

Example 1 with ReprocessContentResultJson

use of com.enonic.xp.impl.server.rest.model.ReprocessContentResultJson in project xp by enonic.

the class ContentResource method reprocess.

@POST
@Path("reprocess")
@Deprecated
public ReprocessContentResultJson reprocess(final ReprocessContentRequestJson request) {
    final List<ContentPath> updated = new ArrayList<>();
    final List<String> errors = new ArrayList<>();
    final Content content = this.contentService.getByPath(request.getSourceBranchPath().getContentPath());
    try {
        reprocessContent(content, request.isSkipChildren(), updated, errors);
    } catch (Exception e) {
        errors.add(String.format("Content '%s' - %s: %s", content.getPath().toString(), e.getClass().getCanonicalName(), e.getMessage()));
        LOG.warn("Error reprocessing content [" + content.getPath() + "]", e);
    }
    return new ReprocessContentResultJson(ContentPaths.from(updated), errors);
}
Also used : Content(com.enonic.xp.content.Content) ArrayList(java.util.ArrayList) ContentPath(com.enonic.xp.content.ContentPath) ReprocessContentResultJson(com.enonic.xp.impl.server.rest.model.ReprocessContentResultJson) Path(javax.ws.rs.Path) ContentPath(com.enonic.xp.content.ContentPath) POST(javax.ws.rs.POST)

Example 2 with ReprocessContentResultJson

use of com.enonic.xp.impl.server.rest.model.ReprocessContentResultJson in project xp by enonic.

the class ReprocessRunnableTask method run.

@Override
public void run(final TaskId id, final ProgressReporter progressReporter) {
    final List<ContentPath> updated = new ArrayList<>();
    final List<String> errors = new ArrayList<>();
    final Content content = this.contentService.getByPath(params.getSourceBranchPath().getContentPath());
    try {
        if (!params.isSkipChildren()) {
            String nodePath = CONTENT_ROOT_PATH.asAbsolute().toString();
            final ContentPath contentPath = params.getSourceBranchPath().getContentPath();
            if (!ContentPath.ROOT.equals(contentPath)) {
                nodePath += content.getPath().asAbsolute().toString();
            }
            final ConstraintExpr pathExpr = CompareExpr.like(FieldExpr.from("_path"), ValueExpr.string(nodePath + "/*"));
            final ContentQuery countChildren = ContentQuery.create().queryExpr(QueryExpr.from(pathExpr)).size(0).build();
            total = (int) contentService.find(countChildren).getTotalHits() + 1;
        }
        reprocessContent(content, params.isSkipChildren(), updated, errors, progressReporter);
    } catch (Exception e) {
        errors.add(String.format("Content '%s' - %s: %s", content.getPath().toString(), e.getClass().getCanonicalName(), e.getMessage()));
        LOG.warn("Error reprocessing content [" + content.getPath() + "]", e);
    }
    progressReporter.info(new ReprocessContentResultJson(ContentPaths.from(updated), errors).toString());
}
Also used : ConstraintExpr(com.enonic.xp.query.expr.ConstraintExpr) ContentQuery(com.enonic.xp.content.ContentQuery) Content(com.enonic.xp.content.Content) ArrayList(java.util.ArrayList) ContentPath(com.enonic.xp.content.ContentPath) ReprocessContentResultJson(com.enonic.xp.impl.server.rest.model.ReprocessContentResultJson)

Aggregations

Content (com.enonic.xp.content.Content)2 ContentPath (com.enonic.xp.content.ContentPath)2 ReprocessContentResultJson (com.enonic.xp.impl.server.rest.model.ReprocessContentResultJson)2 ArrayList (java.util.ArrayList)2 ContentQuery (com.enonic.xp.content.ContentQuery)1 ConstraintExpr (com.enonic.xp.query.expr.ConstraintExpr)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1