@@ -548,8 +548,13 @@ static LifecycleRule fromPb(Rule rule) {
|
548 | 548 | StorageClass.valueOf(action.getStorageClass()));
|
549 | 549 | break;
|
550 | 550 | default:
|
551 |
| -throw new UnsupportedOperationException( |
552 |
| -"The specified lifecycle action " + action.getType() + " is not currently supported"); |
| 551 | +log.warning( |
| 552 | +"The lifecycle action " |
| 553 | ++ action.getType() |
| 554 | ++ " is not supported by this version of the library. " |
| 555 | ++ "Attempting to update with this rule may cause errors. Please " |
| 556 | ++ "update to the latest version of google-cloud-storage."); |
| 557 | +lifecycleAction = LifecycleAction.newLifecycleAction("Unknown action"); |
553 | 558 | }
|
554 | 559 |
|
555 | 560 | Rule.Condition condition = rule.getCondition();
|
@@ -799,13 +804,21 @@ public LifecycleCondition build() {
|
799 | 804 | }
|
800 | 805 |
|
801 | 806 | /**
|
802 |
| -* Base class for the Action to take when a Lifecycle Condition is met. Specific Actions are |
| 807 | +* Base class for the Action to take when a Lifecycle Condition is met. Supported Actions are |
803 | 808 | * expressed as subclasses of this class, accessed by static factory methods.
|
804 | 809 | */
|
805 |
| -public abstract static class LifecycleAction implements Serializable { |
| 810 | +public static class LifecycleAction implements Serializable { |
806 | 811 | private static final long serialVersionUID = 5801228724709173284L;
|
807 | 812 |
|
808 |
| -public abstract String getActionType(); |
| 813 | +private final String actionType; |
| 814 | + |
| 815 | +public LifecycleAction(String actionType) { |
| 816 | +this.actionType = actionType; |
| 817 | +} |
| 818 | + |
| 819 | +public String getActionType() { |
| 820 | +return actionType; |
| 821 | +} |
809 | 822 |
|
810 | 823 | @Override
|
811 | 824 | public String toString() {
|
@@ -830,17 +843,24 @@ public static SetStorageClassLifecycleAction newSetStorageClassAction(
|
830 | 843 | StorageClass storageClass) {
|
831 | 844 | return new SetStorageClassLifecycleAction(storageClass);
|
832 | 845 | }
|
| 846 | + |
| 847 | +/** |
| 848 | +* Creates a new {@code LifecycleAction , with no specific supported action associated with it. This |
| 849 | +* is only intended as a "backup" for when the library doesn't recognize the type, and should |
| 850 | +* generally not be used, instead use the supported actions, and upgrade the library if necessary |
| 851 | +* to get new supported actions. |
| 852 | +*/ |
| 853 | +public static LifecycleAction newLifecycleAction(String actionType) { |
| 854 | +return new LifecycleAction(actionType); |
| 855 | +} |
833 | 856 | }
|
834 | 857 |
|
835 | 858 | public static class DeleteLifecycleAction extends LifecycleAction {
|
836 | 859 | public static final String TYPE = "Delete";
|
837 | 860 | private static final long serialVersionUID = -2050986302222644873L;
|
838 | 861 |
|
839 |
| -private DeleteLifecycleAction() {} |
840 |
| - |
841 |
| -@Override |
842 |
| -public String getActionType() { |
843 |
| -return TYPE; |
| 862 | +private DeleteLifecycleAction() { |
| 863 | +super(TYPE); |
844 | 864 | }
|
845 | 865 | }
|
846 | 866 |
|
@@ -851,14 +871,10 @@ public static class SetStorageClassLifecycleAction extends LifecycleAction {
|
851 | 871 | private final StorageClass storageClass;
|
852 | 872 |
|
853 | 873 | private SetStorageClassLifecycleAction(StorageClass storageClass) {
|
| 874 | +super(TYPE); |
854 | 875 | this.storageClass = storageClass;
|
855 | 876 | }
|
856 | 877 |
|
857 |
| -@Override |
858 |
| -public String getActionType() { |
859 |
| -return TYPE; |
860 |
| -} |
861 |
| - |
862 | 878 | @Override
|
863 | 879 | public String toString() {
|
864 | 880 | return MoreObjects.toStringHelper(this)
|
@@ -1007,7 +1023,11 @@ static class RawDeleteRule extends DeleteRule {
|
1007 | 1023 |
|
1008 | 1024 | @Override
|
1009 | 1025 | void populateCondition(Rule.Condition condition) {
|
1010 |
| -throw new UnsupportedOperationException(); |
| 1026 | +log.warning( |
| 1027 | +"The lifecycle condition " |
| 1028 | ++ condition |
| 1029 | ++ " is not currently supported. Please update to the latest version of google-cloud-java." |
| 1030 | ++ " Also, use LifecycleRule rather than the deprecated DeleteRule."); |
1011 | 1031 | }
|
1012 | 1032 |
|
1013 | 1033 | private void writeObject(ObjectOutputStream out) throws IOException {
|
|
0 commit comments