@@ -462,8 +462,13 @@ static LifecycleRule fromPb(Rule rule) {
462462 StorageClass .valueOf (action .getStorageClass ()));
463463 break ;
464464 default :
465- throw new UnsupportedOperationException (
466- "The specified lifecycle action " + action .getType () + " is not currently supported" );
465+ log .warning (
466+ "The lifecycle action "
467+ + action .getType ()
468+ + " is not supported by this version of the library. "
469+ + "Attempting to update with this rule may cause errors. Please "
470+ + "update to the latest version of google-cloud-storage." );
471+ lifecycleAction = LifecycleAction .newLifecycleAction ("Unknown action" );
467472 }
468473
469474 Rule .Condition condition = rule .getCondition ();
@@ -713,13 +718,21 @@ public LifecycleCondition build() {
713718 }
714719
715720 /**
716- * Base class for the Action to take when a Lifecycle Condition is met. Specific Actions are
721+ * Base class for the Action to take when a Lifecycle Condition is met. Supported Actions are
717722 * expressed as subclasses of this class, accessed by static factory methods.
718723 */
719- public abstract static class LifecycleAction implements Serializable {
724+ public static class LifecycleAction implements Serializable {
720725 private static final long serialVersionUID = 5801228724709173284L ;
721726
722- public abstract String getActionType ();
727+ private final String actionType ;
728+
729+ public LifecycleAction (String actionType ) {
730+ this .actionType = actionType ;
731+ }
732+
733+ public String getActionType () {
734+ return actionType ;
735+ }
723736
724737 @ Override
725738 public String toString () {
@@ -744,17 +757,24 @@ public static SetStorageClassLifecycleAction newSetStorageClassAction(
744757 StorageClass storageClass ) {
745758 return new SetStorageClassLifecycleAction (storageClass );
746759 }
760+
761+ /**
762+ * Creates a new {@code LifecycleAction , with no specific supported action associated with it. This
763+ * is only intended as a "backup" for when the library doesn't recognize the type, and should
764+ * generally not be used, instead use the supported actions, and upgrade the library if necessary
765+ * to get new supported actions.
766+ */
767+ public static LifecycleAction newLifecycleAction (String actionType ) {
768+ return new LifecycleAction (actionType );
769+ }
747770 }
748771
749772 public static class DeleteLifecycleAction extends LifecycleAction {
750773 public static final String TYPE = "Delete" ;
751774 private static final long serialVersionUID = -2050986302222644873L ;
752775
753- private DeleteLifecycleAction () {}
754-
755- @ Override
756- public String getActionType () {
757- return TYPE ;
776+ private DeleteLifecycleAction () {
777+ super (TYPE );
758778 }
759779 }
760780
@@ -765,14 +785,10 @@ public static class SetStorageClassLifecycleAction extends LifecycleAction {
765785 private final StorageClass storageClass ;
766786
767787 private SetStorageClassLifecycleAction (StorageClass storageClass ) {
788+ super (TYPE );
768789 this .storageClass = storageClass ;
769790 }
770791
771- @ Override
772- public String getActionType () {
773- return TYPE ;
774- }
775-
776792 @ Override
777793 public String toString () {
778794 return MoreObjects .toStringHelper (this )
@@ -921,7 +937,11 @@ static class RawDeleteRule extends DeleteRule {
921937
922938 @ Override
923939 void populateCondition (Rule .Condition condition ) {
924- throw new UnsupportedOperationException ();
940+ log .warning (
941+ "The lifecycle condition "
942+ + condition
943+ + " is not currently supported. Please update to the latest version of google-cloud-java."
944+ + " Also, use LifecycleRule rather than the deprecated DeleteRule." );
925945 }
926946
927947 private void writeObject (ObjectOutputStream out ) throws IOException {
0 commit comments