You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2014/07/04 14:46:50 UTC
[08/12] ISIS-833: moved applib services into own modules,
rationalized most of the applib/runtime modules
http://git-wip-us.apache.org/repos/asf/isis/blob/e3c20592/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandJdo.java
----------------------------------------------------------------------
diff --git a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandJdo.java b/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandJdo.java
deleted file mode 100644
index fb5fabc..0000000
--- a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandJdo.java
+++ /dev/null
@@ -1,740 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.objectstore.jdo.applib.service.command;
-
-import java.math.BigDecimal;
-import java.sql.Timestamp;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.atomic.AtomicInteger;
-
-import javax.jdo.annotations.IdentityType;
-import javax.jdo.annotations.NotPersistent;
-
-import com.google.common.collect.Maps;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.applib.DomainObjectContainer;
-import org.apache.isis.applib.annotation.ActionSemantics;
-import org.apache.isis.applib.annotation.ActionSemantics.Of;
-import org.apache.isis.applib.annotation.Bulk;
-import org.apache.isis.applib.annotation.Command.ExecuteIn;
-import org.apache.isis.applib.annotation.Command.Persistence;
-import org.apache.isis.applib.annotation.Hidden;
-import org.apache.isis.applib.annotation.Immutable;
-import org.apache.isis.applib.annotation.Mandatory;
-import org.apache.isis.applib.annotation.MemberGroupLayout;
-import org.apache.isis.applib.annotation.MemberOrder;
-import org.apache.isis.applib.annotation.MultiLine;
-import org.apache.isis.applib.annotation.Named;
-import org.apache.isis.applib.annotation.ObjectType;
-import org.apache.isis.applib.annotation.Programmatic;
-import org.apache.isis.applib.annotation.TypicalLength;
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.applib.services.bookmark.Bookmark;
-import org.apache.isis.applib.services.bookmark.BookmarkService;
-import org.apache.isis.applib.services.command.Command;
-import org.apache.isis.applib.util.ObjectContracts;
-import org.apache.isis.applib.util.TitleBuffer;
-import org.apache.isis.objectstore.jdo.applib.service.DomainChangeJdoAbstract;
-import org.apache.isis.objectstore.jdo.applib.service.JdoColumnLength;
-import org.apache.isis.objectstore.jdo.applib.service.Util;
-import org.apache.isis.objectstore.jdo.applib.service.DomainChangeJdoAbstract.ChangeType;
-
-
-@javax.jdo.annotations.PersistenceCapable(
- identityType=IdentityType.APPLICATION,
- table="IsisCommand")
-@javax.jdo.annotations.Queries( {
- @javax.jdo.annotations.Query(
- name="findByTransactionId", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.command.CommandJdo "
- + "WHERE transactionId == :transactionId "),
- @javax.jdo.annotations.Query(
- name="findBackgroundCommandByTransactionId", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.command.CommandJdo "
- + "WHERE transactionId == :transactionId "
- + "&& executeIn == 'BACKGROUND'"),
- @javax.jdo.annotations.Query(
- name="findBackgroundCommandsByParent", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.command.CommandJdo "
- + "WHERE parent == :parent "
- + "&& executeIn == 'BACKGROUND'"),
- @javax.jdo.annotations.Query(
- name="findBackgroundCommandsNotYetStarted", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.command.CommandJdo "
- + "WHERE executeIn == 'BACKGROUND' "
- + "&& startedAt == null "
- + "ORDER BY timestamp ASC "
- ),
- @javax.jdo.annotations.Query(
- name="findCurrent", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.command.CommandJdo "
- + "WHERE completedAt == null "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="findCompleted", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.command.CommandJdo "
- + "WHERE completedAt != null "
- + "&& executeIn == 'FOREGROUND' "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="findByTargetAndTimestampBetween", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.audit.AuditEntryJdo "
- + "WHERE targetStr == :targetStr "
- + "&& timestamp >= :from "
- + "&& timestamp <= :to "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="findByTargetAndTimestampAfter", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.audit.AuditEntryJdo "
- + "WHERE targetStr == :targetStr "
- + "&& timestamp >= :from "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="findByTargetAndTimestampBefore", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.audit.AuditEntryJdo "
- + "WHERE targetStr == :targetStr "
- + "&& timestamp <= :to "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="findByTarget", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.audit.AuditEntryJdo "
- + "WHERE targetStr == :targetStr "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="findByTimestampBetween", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.audit.AuditEntryJdo "
- + "WHERE timestamp >= :from "
- + "&& timestamp <= :to "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="findByTimestampAfter", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.audit.AuditEntryJdo "
- + "WHERE timestamp >= :from "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="findByTimestampBefore", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.audit.AuditEntryJdo "
- + "WHERE timestamp <= :to "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="find", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.audit.AuditEntryJdo "
- + "ORDER BY timestamp DESC")
-})
-@ObjectType("IsisCommand")
-@MemberGroupLayout(
- columnSpans={6,0,6,12},
- left={"Identifiers","Target","Notes"},
- right={"Detail","Timings","Results"})
-@Named("Command")
-@Immutable
-public class CommandJdo extends DomainChangeJdoAbstract implements Command {
-
- @SuppressWarnings("unused")
- private static final Logger LOG = LoggerFactory.getLogger(CommandJdo.class);
-
- public CommandJdo() {
- super(ChangeType.COMMAND);
- }
-
-
-
- // //////////////////////////////////////
- // Identification
- // //////////////////////////////////////
-
- public String title() {
- final TitleBuffer buf = new TitleBuffer();
- buf.append(getTargetStr());
- buf.append(" ").append(getMemberIdentifier());
- return buf.toString();
- }
-
-
-
- // //////////////////////////////////////
- // user (property)
- // //////////////////////////////////////
-
- private String user;
-
- @javax.jdo.annotations.Column(allowsNull="false", length=JdoColumnLength.USER_NAME)
- @MemberOrder(name="Identifiers", sequence = "10")
- public String getUser() {
- return user;
- }
-
- public void setUser(final String user) {
- this.user = user;
- }
-
-
-
- // //////////////////////////////////////
- // timestamp (property)
- // //////////////////////////////////////
-
- private Timestamp timestamp;
-
- /**
- * The date/time at which this action was created.
- */
- @javax.jdo.annotations.Persistent
- @javax.jdo.annotations.Column(allowsNull="false")
- @MemberOrder(name="Identifiers", sequence = "20")
- public Timestamp getTimestamp() {
- return timestamp;
- }
-
- /**
- * <b>NOT API</b>: intended to be called only by the framework.
- */
- public void setTimestamp(final Timestamp timestamp) {
- this.timestamp = timestamp;
- }
-
-
- // //////////////////////////////////////
- // executor (property)
- // //////////////////////////////////////
-
- private Executor executor;
-
- @Programmatic
- @javax.jdo.annotations.NotPersistent
- @Override
- public Executor getExecutor() {
- return executor;
- }
-
- @Override
- public void setExecutor(Executor nature) {
- this.executor = nature;
- }
-
- // //////////////////////////////////////
- // executeIn (property)
- // //////////////////////////////////////
-
- private ExecuteIn executeIn;
-
- /**
- * Whether the action was invoked explicitly by the user, or scheduled as a background
- * task, or as for some other reason, eg a side-effect of rendering an object due to
- * get-after-post).
- */
- @javax.jdo.annotations.Column(allowsNull="false", length=JdoColumnLength.Command.EXECUTE_IN)
- @MemberOrder(name="Identifiers", sequence = "32")
- @Override
- public ExecuteIn getExecuteIn() {
- return executeIn;
- }
-
- /**
- * <b>NOT API</b>: intended to be called only by the framework.
- */
- @Override
- public void setExecuteIn(ExecuteIn nature) {
- this.executeIn = nature;
- }
-
-
- // //////////////////////////////////////
- // parent (property)
- // //////////////////////////////////////
-
- private Command parent;
-
- @Override
- @javax.jdo.annotations.Persistent
- @javax.jdo.annotations.Column(name="parentTransactionId", allowsNull="true")
- @Hidden(where=Where.PARENTED_TABLES)
- @MemberOrder(name="Identifiers",sequence = "40")
- public Command getParent() {
- return parent;
- }
-
- @Override
- public void setParent(Command parent) {
- this.parent = parent;
- }
-
-
- // //////////////////////////////////////
- // transactionId (property)
- // //////////////////////////////////////
-
-
- private UUID transactionId;
-
- /**
- * The unique identifier (a GUID) of the transaction in which this command occurred.
- */
- @javax.jdo.annotations.PrimaryKey
- @javax.jdo.annotations.Column(allowsNull="false", length=JdoColumnLength.TRANSACTION_ID)
- @TypicalLength(JdoColumnLength.TRANSACTION_ID)
- @MemberOrder(name="Identifiers",sequence = "50")
- @Override
- public UUID getTransactionId() {
- return transactionId;
- }
-
- /**
- * <b>NOT API</b>: intended to be called only by the framework.
- *
- * <p>
- * Implementation notes: copied over from the Isis transaction when the command is persisted.
- */
- @Override
- public void setTransactionId(final UUID transactionId) {
- this.transactionId = transactionId;
- }
-
-
- // //////////////////////////////////////
- // targetClass (property)
- // //////////////////////////////////////
-
- private String targetClass;
-
- @javax.jdo.annotations.Column(allowsNull="false", length=JdoColumnLength.TARGET_CLASS)
- @TypicalLength(30)
- @MemberOrder(name="Target", sequence = "10")
- @Named("Class")
- public String getTargetClass() {
- return targetClass;
- }
-
- public void setTargetClass(final String targetClass) {
- this.targetClass = Util.abbreviated(targetClass, JdoColumnLength.TARGET_CLASS);
- }
-
-
- // //////////////////////////////////////
- // targetAction (property)
- // //////////////////////////////////////
-
- private String targetAction;
-
- @javax.jdo.annotations.Column(allowsNull="false", length=JdoColumnLength.TARGET_ACTION)
- @Mandatory
- @Hidden(where=Where.NOWHERE)
- @TypicalLength(30)
- @MemberOrder(name="Target", sequence = "20")
- @Named("Action")
- public String getTargetAction() {
- return targetAction;
- }
-
- public void setTargetAction(final String targetAction) {
- this.targetAction = Util.abbreviated(targetAction, JdoColumnLength.TARGET_ACTION);
- }
-
-
- // //////////////////////////////////////
- // target (property)
- // openTargetObject (action)
- // //////////////////////////////////////
-
- private String targetStr;
- @javax.jdo.annotations.Column(allowsNull="false", length=JdoColumnLength.BOOKMARK, name="target")
- @Hidden(where=Where.ALL_TABLES)
- @MemberOrder(name="Target", sequence="30")
- @Named("Object")
- public String getTargetStr() {
- return targetStr;
- }
-
- public void setTargetStr(final String targetStr) {
- this.targetStr = targetStr;
- }
-
- // //////////////////////////////////////
- // arguments (property)
- // //////////////////////////////////////
-
- private String arguments;
-
- @javax.jdo.annotations.Column(allowsNull="true", jdbcType="CLOB")
- @MultiLine(numberOfLines=7)
- @Hidden(where=Where.ALL_TABLES)
- @MemberOrder(name="Target",sequence = "40")
- public String getArguments() {
- return arguments;
- }
-
- public void setArguments(final String arguments) {
- this.arguments = arguments;
- }
-
-
-
- // //////////////////////////////////////
- // memberIdentifier (property)
- // //////////////////////////////////////
-
- private String memberIdentifier;
-
- @javax.jdo.annotations.Column(allowsNull="false", length=JdoColumnLength.MEMBER_IDENTIFIER)
- @TypicalLength(60)
- @Hidden(where=Where.ALL_TABLES)
- @MemberOrder(name="Detail",sequence = "1")
- public String getMemberIdentifier() {
- return memberIdentifier;
- }
-
- public void setMemberIdentifier(final String memberIdentifier) {
- this.memberIdentifier = Util.abbreviated(memberIdentifier, JdoColumnLength.MEMBER_IDENTIFIER);
- }
-
-
-
- // //////////////////////////////////////
- // memento (property)
- // //////////////////////////////////////
-
- private String memento;
-
- @javax.jdo.annotations.Column(allowsNull="true", jdbcType="CLOB")
- @MultiLine(numberOfLines=9)
- @Hidden(where=Where.ALL_TABLES)
- @MemberOrder(name="Detail",sequence = "30")
- public String getMemento() {
- return memento;
- }
-
- public void setMemento(final String memento) {
- this.memento = memento;
- }
-
-
-
- // //////////////////////////////////////
- // startedAt (derived property)
- // //////////////////////////////////////
-
- private Timestamp startedAt;
-
- @javax.jdo.annotations.Persistent
- @javax.jdo.annotations.Column(allowsNull="true")
- @MemberOrder(name="Timings", sequence = "3")
- public Timestamp getStartedAt() {
- return startedAt;
- }
-
- /**
- * <b>NOT API</b>: intended to be called only by the framework.
- */
- public void setStartedAt(final Timestamp startedAt) {
- this.startedAt = startedAt;
- }
-
-
-
- // //////////////////////////////////////
- // completedAt (property)
- // //////////////////////////////////////
-
- private Timestamp completedAt;
-
- /**
- * The date/time at which this interaction completed.
- */
- @javax.jdo.annotations.Persistent
- @javax.jdo.annotations.Column(allowsNull="true")
- @MemberOrder(name="Timings", sequence = "4")
- @Override
- public Timestamp getCompletedAt() {
- return completedAt;
- }
-
- @Override
- public void setCompletedAt(final Timestamp completed) {
- this.completedAt = completed;
- }
-
-
- // //////////////////////////////////////
- // duration (derived property)
- // //////////////////////////////////////
-
- /**
- * The number of seconds (to 3 decimal places) that this interaction lasted.
- *
- * <p>
- * Populated only if it has {@link #getCompletedAt() completed}.
- */
- @javax.validation.constraints.Digits(integer=5, fraction=3)
- @Named("Duration")
- @MemberOrder(name="Timings", sequence = "7")
- public BigDecimal getDuration() {
- return Util.durationBetween(getStartedAt(), getCompletedAt());
- }
-
-
-
- // //////////////////////////////////////
- // complete (derived property)
- // //////////////////////////////////////
-
-
- @javax.jdo.annotations.NotPersistent
- @MemberOrder(name="Timings", sequence = "8")
- @Hidden(where=Where.OBJECT_FORMS)
- public boolean isComplete() {
- return getCompletedAt() != null;
- }
-
-
-
- // //////////////////////////////////////
- // state (derived property)
- // //////////////////////////////////////
-
- @javax.jdo.annotations.NotPersistent
- @MemberOrder(name="Results",sequence = "10")
- @Hidden(where=Where.OBJECT_FORMS)
- @Named("Result")
- public String getResultSummary() {
- if(getCompletedAt() == null) {
- return "";
- }
- if(getException() != null) {
- return "EXCEPTION";
- }
- if(getResultStr() != null) {
- return "OK";
- } else {
- return "OK (VOID)";
- }
- }
-
-
- // //////////////////////////////////////
- // result (property)
- // openResultObject (action)
- // //////////////////////////////////////
-
- @Programmatic
- @Override
- public Bookmark getResult() {
- return Util.bookmarkFor(getResultStr());
- }
-
- @Programmatic
- @Override
- public void setResult(Bookmark result) {
- setResultStr(Util.asString(result));
- }
-
- // //////////////////////////////////////
-
- private String resultStr;
-
- @javax.jdo.annotations.Column(allowsNull="true", length=JdoColumnLength.BOOKMARK, name="result")
- @Hidden(where=Where.ALL_TABLES)
- @Named("Result Bookmark")
- @MemberOrder(name="Results", sequence="25")
- public String getResultStr() {
- return resultStr;
- }
-
- public void setResultStr(final String resultStr) {
- this.resultStr = resultStr;
- }
-
- // //////////////////////////////////////
-
- @ActionSemantics(Of.SAFE)
- @MemberOrder(name="ResultStr", sequence="1")
- @Named("Open")
- public Object openResultObject() {
- return Util.lookupBookmark(getResult(), bookmarkService, container);
- }
- public boolean hideOpenResultObject() {
- return getResult() == null;
- }
-
-
- // //////////////////////////////////////
- // exception (property)
- // causedException (derived property)
- // showException (associated action)
- // //////////////////////////////////////
-
- private String exception;
-
- /**
- * Stack trace of any exception that might have occurred if this interaction/transaction aborted.
- *
- * <p>
- * Not visible in the UI, but accessible
- * <p>
- * Not part of the applib API, because the default implementation is not persistent
- * and so there's no object that can be accessed to be annotated.
- */
- @javax.jdo.annotations.Column(allowsNull="true", jdbcType="CLOB")
- @Hidden
- @Override
- public String getException() {
- return exception;
- }
-
- @Override
- public void setException(final String exception) {
- this.exception = exception;
- }
-
-
- // //////////////////////////////////////
-
- @javax.jdo.annotations.NotPersistent
- @MemberOrder(name="Results",sequence = "30")
- @Hidden(where=Where.ALL_TABLES)
- public boolean isCausedException() {
- return getException() != null;
- }
-
-
- // //////////////////////////////////////
-
- @ActionSemantics(Of.SAFE)
- @MemberOrder(name="causedException", sequence = "1")
- public String showException() {
- return getException();
- }
- public boolean hideShowException() {
- return !isCausedException();
- }
-
-
- // //////////////////////////////////////
- // next(...) impl
- // //////////////////////////////////////
-
- private final Map<String, AtomicInteger> sequenceByName = Maps.newHashMap();
-
-
-
- @Programmatic
- @Override
- public int next(String sequenceName) {
- AtomicInteger next = sequenceByName.get(sequenceName);
- if(next == null) {
- next = new AtomicInteger(0);
- sequenceByName.put(sequenceName, next);
- } else {
- next.incrementAndGet();
- }
- return next.get();
- }
-
-
- // //////////////////////////////////////
- // persistence (programmatic)
- // //////////////////////////////////////
-
- private Persistence persistence;
-
- @javax.jdo.annotations.NotPersistent
- @Programmatic
- @Override
- public Persistence getPersistence() {
- return persistence;
- }
-
- @Override
- public void setPersistence(Persistence persistence) {
- this.persistence = persistence;
- }
-
-
- // //////////////////////////////////////
- // setPersistHint (SPI impl)
- // //////////////////////////////////////
-
- private boolean persistHint;
-
- @NotPersistent
- @Programmatic
- public boolean isPersistHint() {
- return persistHint;
- }
-
- @Programmatic
- @Override
- public void setPersistHint(boolean persistHint) {
- this.persistHint = persistHint;
- }
-
-
- // //////////////////////////////////////
-
- @Programmatic
- boolean shouldPersist() {
- if(Persistence.PERSISTED == getPersistence()) {
- return true;
- }
- if(Persistence.IF_HINTED == getPersistence()) {
- return isPersistHint();
- }
- return false;
- }
-
-
-
- // //////////////////////////////////////
- // toString
- // //////////////////////////////////////
-
- @Override
- public String toString() {
- return ObjectContracts.toString(this, "targetStr,memberIdentifier,user,startedAt,completedAt,duration,transactionId");
- }
-
-
-
- // //////////////////////////////////////
- // dependencies
- // //////////////////////////////////////
-
-
- @javax.inject.Inject
- private BookmarkService bookmarkService;
-
- @javax.inject.Inject
- private DomainObjectContainer container;
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/e3c20592/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdo.java
----------------------------------------------------------------------
diff --git a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdo.java b/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdo.java
deleted file mode 100644
index 96a6016..0000000
--- a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdo.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.objectstore.jdo.applib.service.command;
-
-import java.util.UUID;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.applib.AbstractService;
-import org.apache.isis.applib.annotation.Command.ExecuteIn;
-import org.apache.isis.applib.annotation.Command.Persistence;
-import org.apache.isis.applib.annotation.Programmatic;
-import org.apache.isis.applib.clock.Clock;
-import org.apache.isis.applib.services.command.Command;
-import org.apache.isis.applib.services.command.Command.Executor;
-import org.apache.isis.applib.services.command.spi.CommandService;
-
-public class CommandServiceJdo extends AbstractService implements CommandService {
-
- @SuppressWarnings("unused")
- private static final Logger LOG = LoggerFactory.getLogger(CommandServiceJdo.class);
-
- /**
- * Creates an {@link CommandJdo}, initializing its
- * {@link Command#setExecuteIn(Command.ExecuteIn) nature} to be
- * {@link Command.ExecuteIn#OTHER rendering}.
- */
- @Programmatic
- @Override
- public Command create() {
- CommandJdo command = newTransientInstance(CommandJdo.class);
- command.setExecutor(Executor.OTHER);
- command.setPersistence(Persistence.IF_HINTED);
- return command;
- }
-
- @Programmatic
- @Override
- public void startTransaction(final Command command, final UUID transactionId) {
- if(command instanceof CommandJdo) {
- // should be the case, since this service created the object in the #create() method
- final CommandJdo commandJdo = (CommandJdo) command;
- final UUID currentTransactionId = commandJdo.getTransactionId();
- if(currentTransactionId != null && !currentTransactionId.equals(transactionId)) {
- // the logic in IsisTransaction means that any subsequent transactions within a given command
- // should reuse the xactnId of the first transaction created within that interaction.
- throw new IllegalStateException("Attempting to set a different transactionId on command");
- }
- commandJdo.setTransactionId(transactionId);
- }
- }
-
- @Programmatic
- @Override
- public void complete(final Command command) {
- final CommandJdo commandJdo = asUserInitiatedCommandJdo(command);
- if(commandJdo == null) {
- return;
- }
- if(commandJdo.getCompletedAt() != null) {
- // already attempted to complete.
- // chances are, we're here as the result of a redirect following a previous exception
- // so just ignore.
- return;
- }
-
- commandJdo.setCompletedAt(Clock.getTimeAsJavaSqlTimestamp());
- persistIfNotAlready(commandJdo);
- }
-
- @Override
- public boolean persistIfPossible(Command command) {
- if(!(command instanceof CommandJdo)) {
- // ought not to be the case, since this service created the object in the #create() method
- return false;
- }
- final CommandJdo commandJdo = (CommandJdo)command;
- persistIfNotAlready(commandJdo);
- return true;
- }
-
-
- /**
- * Not API, also used by {@link CommandServiceJdoRepository}.
- */
- CommandJdo asUserInitiatedCommandJdo(final Command command) {
- if(!(command instanceof CommandJdo)) {
- // ought not to be the case, since this service created the object in the #create() method
- return null;
- }
- if(command.getExecuteIn() != ExecuteIn.FOREGROUND) {
- return null;
- }
- final CommandJdo commandJdo = (CommandJdo) command;
- return commandJdo.shouldPersist()? commandJdo: null;
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/e3c20592/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdoContributions.java
----------------------------------------------------------------------
diff --git a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdoContributions.java b/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdoContributions.java
deleted file mode 100644
index 3f11db6..0000000
--- a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdoContributions.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.objectstore.jdo.applib.service.command;
-
-import java.util.UUID;
-
-import org.apache.isis.applib.AbstractFactoryAndRepository;
-import org.apache.isis.applib.annotation.Hidden;
-import org.apache.isis.applib.annotation.MemberOrder;
-import org.apache.isis.applib.annotation.NotContributed;
-import org.apache.isis.applib.annotation.NotContributed.As;
-import org.apache.isis.applib.annotation.NotInServiceMenu;
-import org.apache.isis.applib.services.HasTransactionId;
-import org.apache.isis.applib.services.command.Command;
-
-
-@Hidden
-public class CommandServiceJdoContributions extends AbstractFactoryAndRepository {
-
- @NotInServiceMenu
- @NotContributed(As.ASSOCIATION) // ie contributed as an action
- @MemberOrder(name="transactionId", sequence="1")
- public CommandJdo command(final HasTransactionId hasTransactionId) {
- return commandServiceRepository.findByTransactionId(hasTransactionId.getTransactionId());
- }
- /**
- * Hide if the contributee is a {@link Command}, because {@link Command}s already have a
- * {@link Command#getParent() parent} property.
- */
- public boolean hideCommand(final HasTransactionId hasTransactionId) {
- return (hasTransactionId instanceof Command);
- }
- public String disableCommand(final HasTransactionId hasTransactionId) {
- if(hasTransactionId == null) {
- return "No transaction Id";
- }
- final UUID transactionId = hasTransactionId.getTransactionId();
- final boolean command = commandServiceRepository.findByTransactionId(transactionId) == null;
- return command? "No command found for transaction Id": null;
- }
-
-
- // //////////////////////////////////////
-
-
- @javax.inject.Inject
- private CommandServiceJdoRepository commandServiceRepository;
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/e3c20592/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdoRepository.java
----------------------------------------------------------------------
diff --git a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdoRepository.java b/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdoRepository.java
deleted file mode 100644
index a92208c..0000000
--- a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdoRepository.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.objectstore.jdo.applib.service.command;
-
-import java.sql.Timestamp;
-import java.util.List;
-import java.util.UUID;
-
-import org.joda.time.LocalDate;
-
-import org.apache.isis.applib.AbstractFactoryAndRepository;
-import org.apache.isis.applib.annotation.Programmatic;
-import org.apache.isis.applib.query.Query;
-import org.apache.isis.applib.query.QueryDefault;
-import org.apache.isis.applib.services.bookmark.Bookmark;
-import org.apache.isis.applib.services.command.Command;
-import org.apache.isis.applib.services.command.CommandContext;
-
-
-public class CommandServiceJdoRepository extends AbstractFactoryAndRepository {
-
- @Programmatic
- public List<CommandJdo> findByFromAndTo(
- final LocalDate from, final LocalDate to) {
- final Timestamp fromTs = toTimestampStartOfDayWithOffset(from, 0);
- final Timestamp toTs = toTimestampStartOfDayWithOffset(to, 1);
-
- final Query<CommandJdo> query;
- if(from != null) {
- if(to != null) {
- query = new QueryDefault<CommandJdo>(CommandJdo.class,
- "findByTimestampBetween",
- "from", fromTs,
- "to", toTs);
- } else {
- query = new QueryDefault<CommandJdo>(CommandJdo.class,
- "findByTimestampAfter",
- "from", fromTs);
- }
- } else {
- if(to != null) {
- query = new QueryDefault<CommandJdo>(CommandJdo.class,
- "findByTimestampBefore",
- "to", toTs);
- } else {
- query = new QueryDefault<CommandJdo>(CommandJdo.class,
- "find");
- }
- }
- return allMatches(query);
- }
-
-
- @Programmatic
- public CommandJdo findByTransactionId(final UUID transactionId) {
- persistCurrentCommandIfRequired();
- return firstMatch(
- new QueryDefault<CommandJdo>(CommandJdo.class,
- "findByTransactionId",
- "transactionId", transactionId));
- }
-
- @Programmatic
- public List<CommandJdo> findCurrent() {
- persistCurrentCommandIfRequired();
- return allMatches(
- new QueryDefault<CommandJdo>(CommandJdo.class, "findCurrent"));
- }
-
- @Programmatic
- public List<CommandJdo> findCompleted() {
- persistCurrentCommandIfRequired();
- return allMatches(
- new QueryDefault<CommandJdo>(CommandJdo.class, "findCompleted"));
- }
-
- private void persistCurrentCommandIfRequired() {
- if(commandContext == null || commandService == null) {
- return;
- }
- final Command command = commandContext.getCommand();
- final CommandJdo commandJdo = commandService.asUserInitiatedCommandJdo(command);
- if(commandJdo == null) {
- return;
- }
- persistIfNotAlready(commandJdo);
- }
-
- // //////////////////////////////////////
-
-
- @Programmatic
- public List<CommandJdo> findByTargetAndFromAndTo(
- final Bookmark target, final LocalDate from, final LocalDate to) {
- final String targetStr = target.toString();
- final Timestamp fromTs = toTimestampStartOfDayWithOffset(from, 0);
- final Timestamp toTs = toTimestampStartOfDayWithOffset(to, 1);
-
- final Query<CommandJdo> query;
- if(from != null) {
- if(to != null) {
- query = new QueryDefault<CommandJdo>(CommandJdo.class,
- "findByTargetAndTimestampBetween",
- "targetStr", targetStr,
- "from", fromTs,
- "to", toTs);
- } else {
- query = new QueryDefault<CommandJdo>(CommandJdo.class,
- "findByTargetAndTimestampAfter",
- "targetStr", targetStr,
- "from", fromTs);
- }
- } else {
- if(to != null) {
- query = new QueryDefault<CommandJdo>(CommandJdo.class,
- "findByTargetAndTimestampBefore",
- "targetStr", targetStr,
- "to", toTs);
- } else {
- query = new QueryDefault<CommandJdo>(CommandJdo.class,
- "findByTarget",
- "targetStr", targetStr);
- }
- }
- return allMatches(query);
- }
-
- private static Timestamp toTimestampStartOfDayWithOffset(final LocalDate dt, int daysOffset) {
- return dt!=null
- ?new java.sql.Timestamp(dt.toDateTimeAtStartOfDay().plusDays(daysOffset).getMillis())
- :null;
- }
-
- // //////////////////////////////////////
-
-
- @javax.inject.Inject
- private CommandServiceJdo commandService;
-
- @javax.inject.Inject
- private CommandContext commandContext;
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/e3c20592/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerCompositeForJdoObjectStore.java
----------------------------------------------------------------------
diff --git a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerCompositeForJdoObjectStore.java b/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerCompositeForJdoObjectStore.java
deleted file mode 100644
index a985243..0000000
--- a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerCompositeForJdoObjectStore.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.objectstore.jdo.applib.service.exceprecog;
-
-import org.apache.isis.applib.annotation.Hidden;
-import org.apache.isis.applib.services.exceprecog.ExceptionRecognizer;
-import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerComposite;
-
-/**
- * Convenience implementation of the {@link ExceptionRecognizer} domain service that
- * recognizes a number of common and non-fatal exceptions (such as unique constraint
- * violations).
- *
- * <p>
- * If using the JDO Object store, either register in <tt>isis.properties</tt>, or
- * compose your own, out of the underlying more fine-grained {@link ExceptionRecognizer} implementations.
- */
-@Hidden
-public class ExceptionRecognizerCompositeForJdoObjectStore extends ExceptionRecognizerComposite {
-
-
- public ExceptionRecognizerCompositeForJdoObjectStore() {
- // most specific ones first
- add(new ExceptionRecognizerForSQLIntegrityConstraintViolationUniqueOrIndexException());
- add(new ExceptionRecognizerForJDOObjectNotFoundException());
- add(new ExceptionRecognizerForJDODataStoreException());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/e3c20592/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerForJDODataStoreException.java
----------------------------------------------------------------------
diff --git a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerForJDODataStoreException.java b/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerForJDODataStoreException.java
deleted file mode 100644
index a79e090..0000000
--- a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerForJDODataStoreException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.objectstore.jdo.applib.service.exceprecog;
-
-import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerForType;
-
-public class ExceptionRecognizerForJDODataStoreException extends ExceptionRecognizerForType {
-
- public ExceptionRecognizerForJDODataStoreException() {
- super(ofTypeExcluding(javax.jdo.JDODataStoreException.class, "NOT NULL check constraint"),
- prefix("Unable to save changes. " +
- "Does similar data already exist, or has referenced data been deleted?"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/e3c20592/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerForJDOObjectNotFoundException.java
----------------------------------------------------------------------
diff --git a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerForJDOObjectNotFoundException.java b/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerForJDOObjectNotFoundException.java
deleted file mode 100644
index c80a30a..0000000
--- a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerForJDOObjectNotFoundException.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.objectstore.jdo.applib.service.exceprecog;
-
-import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerForType;
-
-public class ExceptionRecognizerForJDOObjectNotFoundException extends ExceptionRecognizerForType {
-
- public ExceptionRecognizerForJDOObjectNotFoundException() {
- super(javax.jdo.JDOObjectNotFoundException.class,
- prefix("Unable to load object. " +
- "Has it been deleted by someone else?"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/e3c20592/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerForSQLIntegrityConstraintViolationUniqueOrIndexException.java
----------------------------------------------------------------------
diff --git a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerForSQLIntegrityConstraintViolationUniqueOrIndexException.java b/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerForSQLIntegrityConstraintViolationUniqueOrIndexException.java
deleted file mode 100644
index eadaa30..0000000
--- a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/exceprecog/ExceptionRecognizerForSQLIntegrityConstraintViolationUniqueOrIndexException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.objectstore.jdo.applib.service.exceprecog;
-
-import org.apache.isis.applib.services.exceprecog.ExceptionRecognizerForType;
-
-public class ExceptionRecognizerForSQLIntegrityConstraintViolationUniqueOrIndexException extends ExceptionRecognizerForType {
-
- public ExceptionRecognizerForSQLIntegrityConstraintViolationUniqueOrIndexException() {
- super(ofTypeIncluding(java.sql.SQLIntegrityConstraintViolationException.class, "unique constraint or index violation"),
- prefix("Data already exists"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/e3c20592/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/IoUtils.java
----------------------------------------------------------------------
diff --git a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/IoUtils.java b/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/IoUtils.java
deleted file mode 100644
index d7f1ae0..0000000
--- a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/IoUtils.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.objectstore.jdo.applib.service.publish;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-import java.util.zip.ZipOutputStream;
-
-import org.apache.isis.applib.FatalException;
-import org.apache.isis.applib.RecoverableException;
-import org.apache.isis.applib.NonRecoverableException;
-
-class IoUtils {
-
- public static byte[] toUtf8ZippedBytes(String entryName, final String toZip) {
- if(toZip == null) {
- return null;
- }
- ZipOutputStream zos = null;
- ByteArrayOutputStream baos = null;
- try {
- baos = new ByteArrayOutputStream();
- zos = new ZipOutputStream(baos);
- ZipEntry entry = new ZipEntry(entryName);
- zos.putNextEntry(entry);
-
- final byte[] utf8Bytes = toZip.getBytes(Charset.forName("UTF-8"));
- zos.write(utf8Bytes);
- zos.flush();
- } catch (final IOException ex) {
- throw new FatalException(ex);
- } finally {
- closeSafely(zos);
- }
- return baos.toByteArray();
- }
-
- public static String fromUtf8ZippedBytes(String entryName, final byte[] toUnzip) {
- if(toUnzip == null) {
- return null;
- }
- ByteArrayInputStream bais = null;
- ZipInputStream zis = null;
- try {
- bais = new ByteArrayInputStream(toUnzip);
- zis = new ZipInputStream(bais);
- ZipEntry entry;
- while ((entry = zis.getNextEntry()) != null) {
- if(!entry.getName().equals(entryName)) {
- zis.closeEntry();
- continue;
- }
- final byte[] utf8Bytes = IoUtils.readBytes(zis);
- return new String(utf8Bytes, Charset.forName("UTF-8"));
- }
- return null;
- } catch(IOException ex) {
- throw new NonRecoverableException(ex);
- } finally {
- IoUtils.closeSafely(zis);
- }
- }
-
- static byte[] readBytes(final InputStream zis) throws IOException {
- final byte[] buffer = new byte[2048];
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- int numBytes;
- while ((numBytes = zis.read(buffer, 0, buffer.length)) != -1) {
- baos.write(buffer, 0, numBytes);
- }
- baos.flush();
- baos.close();
- return baos.toByteArray();
- }
-
- static void closeSafely(ZipInputStream zis) {
- if(zis != null) {
- try {
- zis.closeEntry();
- } catch (IOException e) {
- // ignore
- }
- try {
- zis.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
-
- static void closeSafely(ZipOutputStream zos) {
- if(zos != null) {
- try {
- zos.closeEntry();
- } catch (IOException e) {
- // ignore
- }
- try {
- zos.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/e3c20592/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishedEventJdo.java
----------------------------------------------------------------------
diff --git a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishedEventJdo.java b/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishedEventJdo.java
deleted file mode 100644
index e74c241..0000000
--- a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishedEventJdo.java
+++ /dev/null
@@ -1,506 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.objectstore.jdo.applib.service.publish;
-
-import java.util.UUID;
-
-import javax.jdo.annotations.IdentityType;
-
-import org.apache.isis.applib.DomainObjectContainer;
-import org.apache.isis.applib.Identifier;
-import org.apache.isis.applib.annotation.ActionSemantics;
-import org.apache.isis.applib.annotation.ActionSemantics.Of;
-import org.apache.isis.applib.annotation.Bulk;
-import org.apache.isis.applib.annotation.Hidden;
-import org.apache.isis.applib.annotation.Immutable;
-import org.apache.isis.applib.annotation.MemberGroupLayout;
-import org.apache.isis.applib.annotation.MemberOrder;
-import org.apache.isis.applib.annotation.MultiLine;
-import org.apache.isis.applib.annotation.Named;
-import org.apache.isis.applib.annotation.NotPersisted;
-import org.apache.isis.applib.annotation.ObjectType;
-import org.apache.isis.applib.annotation.Programmatic;
-import org.apache.isis.applib.annotation.TypicalLength;
-import org.apache.isis.applib.annotation.Where;
-import org.apache.isis.applib.services.HasTransactionId;
-import org.apache.isis.applib.services.bookmark.Bookmark;
-import org.apache.isis.applib.services.bookmark.BookmarkService;
-import org.apache.isis.applib.services.publish.EventType;
-import org.apache.isis.applib.util.ObjectContracts;
-import org.apache.isis.applib.util.TitleBuffer;
-import org.apache.isis.objectstore.jdo.applib.service.DomainChangeJdoAbstract;
-import org.apache.isis.objectstore.jdo.applib.service.JdoColumnLength;
-import org.apache.isis.objectstore.jdo.applib.service.Util;
-import org.apache.isis.objectstore.jdo.applib.service.DomainChangeJdoAbstract.ChangeType;
-
-@javax.jdo.annotations.PersistenceCapable(
- identityType=IdentityType.APPLICATION,
- table="IsisPublishedEvent",
- objectIdClass=PublishedEventJdoPK.class)
-@javax.jdo.annotations.Queries( {
- @javax.jdo.annotations.Query(
- name="findByStateOrderByTimestamp", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.publish.PublishedEventJdo "
- + "WHERE state == :state "
- + "ORDER BY timestamp"),
- @javax.jdo.annotations.Query(
- name="findByTransactionId", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.publish.PublishedEventJdo "
- + "WHERE transactionId == :transactionId"),
- @javax.jdo.annotations.Query(
- name="findByTargetAndTimestampBetween", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.publish.PublishedEventJdo "
- + "WHERE targetStr == :targetStr "
- + "&& timestamp >= :from "
- + "&& timestamp <= :to "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="findByTargetAndTimestampAfter", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.publish.PublishedEventJdo "
- + "WHERE targetStr == :targetStr "
- + "&& timestamp >= :from "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="findByTargetAndTimestampBefore", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.publish.PublishedEventJdo "
- + "WHERE targetStr == :targetStr "
- + "&& timestamp <= :to "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="findByTarget", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.publish.PublishedEventJdo "
- + "WHERE targetStr == :targetStr "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="findByTimestampBetween", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.publish.PublishedEventJdo "
- + "WHERE timestamp >= :from "
- + "&& timestamp <= :to "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="findByTimestampAfter", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.publish.PublishedEventJdo "
- + "WHERE timestamp >= :from "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="findByTimestampBefore", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.publish.PublishedEventJdo "
- + "WHERE timestamp <= :to "
- + "ORDER BY timestamp DESC"),
- @javax.jdo.annotations.Query(
- name="find", language="JDOQL",
- value="SELECT "
- + "FROM org.apache.isis.objectstore.jdo.applib.service.publish.PublishedEventJdo "
- + "ORDER BY timestamp DESC")
-})
-@MemberGroupLayout(
- columnSpans={6,0,6},
- left={"Identifiers","Target"},
- right={"Detail","State"})
-@Immutable
-@Named("Published Event")
-@ObjectType("IsisPublishedEvent")
-public class PublishedEventJdo extends DomainChangeJdoAbstract implements HasTransactionId {
-
- public static enum State {
- QUEUED, PROCESSED
- }
-
- // //////////////////////////////////////
-
- public PublishedEventJdo() {
- super(ChangeType.PUBLISHED_EVENT);
- }
-
-
- // //////////////////////////////////////
- // Identification
- // //////////////////////////////////////
-
- public String title() {
- final TitleBuffer buf = new TitleBuffer();
- buf.append(getEventType().name()).append(" ").append(getTargetStr());
- if(getEventType()==EventType.ACTION_INVOCATION) {
- buf.append(" ").append(getMemberIdentifier());
- }
- buf.append(",").append(getState());
- return buf.toString();
- }
-
-
- // //////////////////////////////////////
- // user (property)
- // //////////////////////////////////////
-
- private String user;
-
- @javax.jdo.annotations.Column(allowsNull="false", length=50)
- @MemberOrder(name="Identifiers", sequence = "10")
- @Hidden(where=Where.PARENTED_TABLES)
- public String getUser() {
- return user;
- }
-
- public void setUser(final String user) {
- this.user = user;
- }
-
-
- // //////////////////////////////////////
- // timestamp (property)
- // //////////////////////////////////////
-
- private java.sql.Timestamp timestamp;
-
- @javax.jdo.annotations.Persistent
- @javax.jdo.annotations.Column(allowsNull="false")
- @MemberOrder(name="Identifiers", sequence = "20")
- @Hidden(where=Where.PARENTED_TABLES)
- public java.sql.Timestamp getTimestamp() {
- return timestamp;
- }
-
- public void setTimestamp(final java.sql.Timestamp timestamp) {
- this.timestamp = timestamp;
- }
-
-
-
- // //////////////////////////////////////
- // transactionId
- // //////////////////////////////////////
-
- private UUID transactionId;
-
- /**
- * The unique identifier (a GUID) of the transaction in which this published event was persisted.
- *
- * <p>
- * The combination of ({@link #getTransactionId() transactionId}, {@link #getSequence() sequence}) makes up the
- * primary key.
- */
- @javax.jdo.annotations.PrimaryKey
- @javax.jdo.annotations.Column(allowsNull="false",length=JdoColumnLength.TRANSACTION_ID)
- @MemberOrder(name="Identifiers", sequence = "30")
- @Hidden(where=Where.PARENTED_TABLES)
- @Override
- public UUID getTransactionId() {
- return transactionId;
- }
-
- @Override
- public void setTransactionId(final UUID transactionId) {
- this.transactionId = transactionId;
- }
-
-
- // //////////////////////////////////////
- // sequence
- // //////////////////////////////////////
-
- private int sequence;
-
- /**
- * The 0-based additional identifier of a published event within the given {@link #getTransactionId() transaction}.
- *
- * <p>
- * The combination of ({@link #getTransactionId() transactionId}, {@link #getSequence() sequence}) makes up the
- * primary key.
- */
- @javax.jdo.annotations.PrimaryKey
- @MemberOrder(name="Identifiers", sequence = "40")
- public int getSequence() {
- return sequence;
- }
-
- public void setSequence(final int sequence) {
- this.sequence = sequence;
- }
-
-
- // //////////////////////////////////////
- // title
- // //////////////////////////////////////
-
- private String title;
-
- /**
- * Consists of the full oidStr (with version info etc), concatenated
- * (if an {@link EventType#ACTION_INVOCATION}) with the name/parms of the action.
- *
- * <p>
- * @deprecated - the oid of the target is also available (without the version info) through {@link #getTarget()}, and
- * the action identifier is available through {@link #getMemberIdentifier()}.
- */
- @javax.jdo.annotations.Column(allowsNull="false", length=JdoColumnLength.PublishedEvent.TITLE)
- @Hidden
- @Deprecated
- public String getTitle() {
- return title;
- }
-
- public void setTitle(final String title) {
- this.title = title;
- }
-
-
- // //////////////////////////////////////
- // eventType (property)
- // //////////////////////////////////////
-
- private EventType eventType;
-
- @javax.jdo.annotations.Column(allowsNull="false", length=JdoColumnLength.PublishedEvent.EVENT_TYPE)
- @MemberOrder(name="Identifiers",sequence = "50")
- public EventType getEventType() {
- return eventType;
- }
-
- public void setEventType(final EventType eventType) {
- this.eventType = eventType;
- }
-
-
- // //////////////////////////////////////
- // targetClass (property)
- // //////////////////////////////////////
-
- private String targetClass;
-
- @javax.jdo.annotations.Column(allowsNull="false", length=JdoColumnLength.TARGET_CLASS)
- @TypicalLength(30)
- @MemberOrder(name="Target", sequence = "10")
- @Named("Class")
- public String getTargetClass() {
- return targetClass;
- }
-
- public void setTargetClass(final String targetClass) {
- this.targetClass = Util.abbreviated(targetClass, JdoColumnLength.TARGET_CLASS);
- }
-
-
- // //////////////////////////////////////
- // targetAction (property)
- // //////////////////////////////////////
-
- private String targetAction;
-
- /**
- * Only populated for {@link EventType#ACTION_INVOCATION}
- */
- @javax.jdo.annotations.Column(allowsNull="true", length=JdoColumnLength.TARGET_ACTION)
- @TypicalLength(30)
- @MemberOrder(name="Target", sequence = "20")
- @Named("Action")
- public String getTargetAction() {
- return targetAction;
- }
-
- public void setTargetAction(final String targetAction) {
- this.targetAction = Util.abbreviated(targetAction, JdoColumnLength.TARGET_ACTION);
- }
-
-
- // //////////////////////////////////////
- // target (property)
- // openTargetObject (action)
- // //////////////////////////////////////
-
-
- private String targetStr;
- @javax.jdo.annotations.Column(allowsNull="false", length=JdoColumnLength.BOOKMARK, name="target")
- @MemberOrder(name="Target", sequence="30")
- @Named("Object")
- public String getTargetStr() {
- return targetStr;
- }
-
- public void setTargetStr(final String targetStr) {
- this.targetStr = targetStr;
- }
-
-
- // //////////////////////////////////////
- // memberIdentifier (property)
- // //////////////////////////////////////
-
- private String memberIdentifier;
-
- /**
- * Holds a string representation of the invoked action, equivalent to
- * {@link Identifier#toClassAndNameIdentityString()}.
- *
- * <p>
- * Only populated for {@link EventType#ACTION_INVOCATION},
- * returns <tt>null</tt> otherwise.
- *
- * <p>
- * This property is called 'memberIdentifier' rather than 'actionIdentifier' for
- * consistency with other services (such as auditing and publishing) that may act on
- * properties rather than simply just actions.
- */
- @javax.jdo.annotations.Column(allowsNull="true", length=JdoColumnLength.MEMBER_IDENTIFIER)
- @TypicalLength(60)
- @Hidden(where=Where.ALL_TABLES)
- @MemberOrder(name="Detail",sequence = "20")
- public String getMemberIdentifier() {
- return memberIdentifier;
- }
-
- public void setMemberIdentifier(final String actionIdentifier) {
- this.memberIdentifier = Util.abbreviated(actionIdentifier, JdoColumnLength.MEMBER_IDENTIFIER);
- }
-
-
-
- // //////////////////////////////////////
- // state (property)
- // //////////////////////////////////////
-
- private State state;
-
- @javax.jdo.annotations.Column(allowsNull="false", length=JdoColumnLength.PublishedEvent.STATE)
- @MemberOrder(name="State", sequence = "30")
- public State getState() {
- return state;
- }
-
- public void setState(final State state) {
- this.state = state;
- }
- private PublishedEventJdo setStateAndReturn(State state) {
- setState(state);
- return this;
- }
-
-
- // //////////////////////////////////////
- // serializedFormZipped (property)
- // serializedForm (derived property)
- // //////////////////////////////////////
-
- @javax.jdo.annotations.NotPersistent
- @NotPersisted
- @MultiLine(numberOfLines=14)
- @Hidden(where=Where.ALL_TABLES)
- @MemberOrder(name="Detail", sequence = "40")
- public String getSerializedForm() {
- byte[] zipped = getSerializedFormZipped();
- if(zipped != null) {
- return PublishingServiceJdo.fromZippedBytes(zipped);
- } else {
- return getSerializedFormClob();
- }
- }
-
-
- // //////////////////////////////////////
-
- @Deprecated
- @javax.jdo.annotations.Column(allowsNull="true")
- private byte[] serializedFormZipped;
-
- @Deprecated
- @Programmatic // ignored by Isis
- public byte[] getSerializedFormZipped() {
- return serializedFormZipped;
- }
-
- @Deprecated
- public void setSerializedFormZipped(final byte[] serializedFormZipped) {
- this.serializedFormZipped = serializedFormZipped;
- }
-
- // //////////////////////////////////////
-
- private String serializedFormClob;
-
- @Programmatic // ignored by Isis
- @javax.jdo.annotations.Column(allowsNull="true", jdbcType="CLOB")
- public String getSerializedFormClob() {
- return serializedFormClob;
- }
-
- public void setSerializedFormClob(final String serializedFormClob) {
- this.serializedFormClob = serializedFormClob;
- }
-
-
- // //////////////////////////////////////
- // processed (action)
- // reQueue (action)
- // delete (action)
- // //////////////////////////////////////
-
-
- @Bulk
- @ActionSemantics(Of.IDEMPOTENT)
- @MemberOrder( name="State", sequence="10")
- public PublishedEventJdo processed() {
- return setStateAndReturn(State.PROCESSED);
- }
-
-
- @Bulk
- @ActionSemantics(Of.IDEMPOTENT)
- @MemberOrder(name="State", sequence="11")
- public PublishedEventJdo reQueue() {
- return setStateAndReturn(State.QUEUED);
- }
-
- @Bulk
- @MemberOrder(name="State", sequence="12")
- public void delete() {
- container.removeIfNotAlready(this);
- }
-
-
-
- // //////////////////////////////////////
- // toString
- // //////////////////////////////////////
-
- @Override
- public String toString() {
- return ObjectContracts.toString(this, "targetStr,timestamp,user,eventType,memberIdentifier,state");
- }
-
-
- // //////////////////////////////////////
- // dependencies
- // //////////////////////////////////////
-
- @javax.inject.Inject
- private BookmarkService bookmarkService;
-
- @javax.inject.Inject
- private DomainObjectContainer container;
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/e3c20592/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishedEventJdoPK.java
----------------------------------------------------------------------
diff --git a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishedEventJdoPK.java b/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishedEventJdoPK.java
deleted file mode 100644
index 0666ed3..0000000
--- a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishedEventJdoPK.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.objectstore.jdo.applib.service.publish;
-
-import java.io.Serializable;
-import java.util.StringTokenizer;
-import java.util.UUID;
-
-public class PublishedEventJdoPK implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private static final String SEPARATOR = "_";
-
- public UUID transactionId;
- public int sequence;
-
- // //////////////////////////////////////
-
-
- public PublishedEventJdoPK() {
- }
-
- public PublishedEventJdoPK(final String value) {
- final StringTokenizer token = new StringTokenizer (value, SEPARATOR);
- this.transactionId = UUID.fromString(token.nextToken());
- this.sequence = Integer.parseInt(token.nextToken());
- }
-
- // //////////////////////////////////////
-
- public UUID getTransactionId() {
- return transactionId;
- }
- public void setTransactionId(UUID transactionId) {
- this.transactionId = transactionId;
- }
-
- // //////////////////////////////////////
-
- public int getSequence() {
- return sequence;
- }
- public void setSequence(int sequence) {
- this.sequence = sequence;
- }
-
- // //////////////////////////////////////
-
-
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + sequence;
- result = prime * result + ((transactionId == null) ? 0 : transactionId.hashCode());
- return result;
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- PublishedEventJdoPK other = (PublishedEventJdoPK) obj;
- if (sequence != other.sequence)
- return false;
- if (transactionId == null) {
- if (other.transactionId != null)
- return false;
- } else if (!transactionId.equals(other.transactionId))
- return false;
- return true;
- }
-
- // //////////////////////////////////////
-
-
- @Override
- public String toString() {
- return transactionId + SEPARATOR + sequence;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/e3c20592/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishingServiceJdo.java
----------------------------------------------------------------------
diff --git a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishingServiceJdo.java b/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishingServiceJdo.java
deleted file mode 100644
index fa08038..0000000
--- a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishingServiceJdo.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.objectstore.jdo.applib.service.publish;
-
-import java.util.Map;
-
-import javax.annotation.PostConstruct;
-
-import com.google.common.base.Strings;
-
-import org.apache.isis.applib.AbstractService;
-import org.apache.isis.applib.annotation.Programmatic;
-import org.apache.isis.applib.services.bookmark.Bookmark;
-import org.apache.isis.applib.services.command.CommandContext;
-import org.apache.isis.applib.services.publish.EventMetadata;
-import org.apache.isis.applib.services.publish.EventPayload;
-import org.apache.isis.applib.services.publish.EventSerializer;
-import org.apache.isis.applib.services.publish.PublishingService;
-
-/**
- * An implementation of {@link PublishingService} that persists events as
- * entities into a JDO-backed database.
- */
-public class PublishingServiceJdo extends AbstractService implements PublishingService {
-
- private static final String SERIALIZED_FORM_LOCAL_KEY = "datanucleus.PublishingService.serializedForm";
- private final static String SERIALIZED_FORM_KEY = "isis.persistor." + SERIALIZED_FORM_LOCAL_KEY;
-
- static enum SerializedForm {
- CLOB,
- @Deprecated
- ZIPPED;
- static SerializedForm parse(final String value) {
- return CLOB.toString().equalsIgnoreCase(value)? CLOB: ZIPPED;
- }
- }
-
- private SerializedForm serializedForm;
-
- @Programmatic
- @PostConstruct
- public void init(Map<String,String> configuration) {
- ensureDependenciesInjected();
- serializedForm = SerializedForm.parse(configuration.get(SERIALIZED_FORM_KEY));
- }
-
-
- // //////////////////////////////////////
-
- private void ensureDependenciesInjected() {
- if(this.commandContext == null) {
- throw new IllegalStateException(this.getClassName() + " requires CommandContext service to be configured");
- }
- if(this.eventSerializer == null) {
- throw new IllegalStateException(this.getClassName() + " requires EventSerializer service to be configured");
- }
- }
-
-
- @Override
- @Programmatic
- public void publish(final EventMetadata metadata, final EventPayload payload) {
- final String serializedEvent = eventSerializer.serialize(metadata, payload).toString();
- final PublishedEventJdo publishedEvent = newTransientInstance(PublishedEventJdo.class);
-
- if(this.serializedForm == SerializedForm.ZIPPED) {
- final byte[] zippedBytes = asZippedBytes(serializedEvent);
- publishedEvent.setSerializedFormZipped(zippedBytes);
- } else {
- publishedEvent.setSerializedFormClob(serializedEvent);
- }
-
- publishedEvent.setTransactionId(metadata.getTransactionId());
- publishedEvent.setSequence(metadata.getSequence());
- publishedEvent.setEventType(metadata.getEventType());
- publishedEvent.setTimestamp(metadata.getJavaSqlTimestamp());
- publishedEvent.setUser(metadata.getUser());
- publishedEvent.setTitle(metadata.getTitle());
-
- publishedEvent.setTargetClass(metadata.getTargetClass());
- publishedEvent.setTarget(metadata.getTarget());
- publishedEvent.setTargetAction(metadata.getTargetAction());
- publishedEvent.setMemberIdentifier(metadata.getActionIdentifier());
-
- persist(publishedEvent);
- }
-
-
- static byte[] asZippedBytes(final String serializedEvent) {
- return IoUtils.toUtf8ZippedBytes("serializedForm", serializedEvent);
- }
-
-
- // //////////////////////////////////////
-
- private EventSerializer eventSerializer;
-
- @Override
- public void setEventSerializer(EventSerializer eventSerializer) {
- this.eventSerializer = eventSerializer;
- }
-
- static String fromZippedBytes(byte[] zipped) {
- return IoUtils.fromUtf8ZippedBytes("serializedForm", zipped);
- }
-
-
- @javax.inject.Inject
- private CommandContext commandContext;
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/e3c20592/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishingServiceJdoContributions.java
----------------------------------------------------------------------
diff --git a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishingServiceJdoContributions.java b/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishingServiceJdoContributions.java
deleted file mode 100644
index 1709f64..0000000
--- a/core/objectstore-jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/publish/PublishingServiceJdoContributions.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.isis.objectstore.jdo.applib.service.publish;
-
-import java.util.List;
-
-import org.apache.isis.applib.AbstractFactoryAndRepository;
-import org.apache.isis.applib.annotation.ActionSemantics;
-import org.apache.isis.applib.annotation.Render;
-import org.apache.isis.applib.annotation.ActionSemantics.Of;
-import org.apache.isis.applib.annotation.NotContributed;
-import org.apache.isis.applib.annotation.NotContributed.As;
-import org.apache.isis.applib.annotation.Render.Type;
-import org.apache.isis.applib.annotation.NotInServiceMenu;
-import org.apache.isis.applib.services.HasTransactionId;
-
-
-public class PublishingServiceJdoContributions extends AbstractFactoryAndRepository {
-
- @ActionSemantics(Of.SAFE)
- @NotInServiceMenu
- @NotContributed(As.ACTION)
- @Render(Type.EAGERLY)
- public List<PublishedEventJdo> publishedEvents(final HasTransactionId hasTransactionId) {
- return publishedEventRepository.findByTransactionId(hasTransactionId.getTransactionId());
- }
-
- // //////////////////////////////////////
-
- @javax.inject.Inject
- private PublishingServiceJdoRepository publishedEventRepository;
-
-}