use of com.enonic.xp.lib.content.mapper.ContentMapper in project xp by enonic.
the class ModifyContentHandler method doExecute.
@Override
protected Object doExecute() {
final Content existingContent = getExistingContent(this.key);
if (existingContent == null) {
return null;
}
final UpdateContentParams params = new UpdateContentParams();
params.contentId(existingContent.getId());
params.editor(newContentEditor(existingContent));
params.requireValid(this.requireValid);
final Content result = this.contentService.update(params);
return result != null ? new ContentMapper(result) : null;
}
use of com.enonic.xp.lib.content.mapper.ContentMapper in project xp by enonic.
the class CreateContentHandler method doExecute.
@Override
protected Object doExecute() {
if (nullToEmpty(this.name).isBlank() && !nullToEmpty(this.displayName).isBlank() && !nullToEmpty(this.parentPath).isBlank()) {
this.name = generateUniqueContentName(ContentPath.from(this.parentPath), this.displayName);
}
if (nullToEmpty(this.displayName).isBlank() && !nullToEmpty(this.name).isBlank()) {
this.displayName = this.name;
}
final CreateContentParams params = createParams();
final Content result = this.contentService.create(params);
return new ContentMapper(result);
}
use of com.enonic.xp.lib.content.mapper.ContentMapper in project xp by enonic.
the class CreateMediaHandler method doExecute.
@Override
protected Object doExecute() {
String name = this.name;
Content result = null;
final ContentPath parent = this.parentPath != null ? ContentPath.from(this.parentPath) : ContentPath.ROOT;
while (result == null) {
final CreateMediaParams params = createParams(name);
try {
result = this.contentService.create(params);
} catch (ContentAlreadyExistsException e) {
name = generateUniqueContentName(this.idGenerator, parent, this.name);
}
}
return new ContentMapper(result);
}
Aggregations