001/* 002 * Copyright 2016 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.workspaces.activities.documents; 017 018import java.util.Map; 019 020import javax.jcr.RepositoryException; 021 022import org.ametys.plugins.explorer.ObservationConstants; 023import org.ametys.plugins.explorer.resources.jcr.JCRResource; 024import org.ametys.plugins.repository.activities.Activity; 025import org.ametys.plugins.repository.activities.ActivityType; 026import org.ametys.plugins.workspaces.activities.documents.AbstractResourceReferenceElementType.ResourceReference; 027 028/** 029 * {@link ActivityType} implementation for the creation of a resource 030 */ 031public class ResourceRenamedActivityType extends DocumentsActivityType 032{ 033 @Override 034 public void setAdditionalActivityData(Activity activity, Map<String, Object> parameters) throws RepositoryException 035 { 036 super.setAdditionalActivityData(activity, parameters); 037 038 // File data 039 String resourceName = (String) parameters.get(ObservationConstants.ARGS_NAME); 040 String resourceOldName = (String) parameters.get("object.old.name"); 041 String resourceId = (String) parameters.get(ObservationConstants.ARGS_ID); 042 043 // Store a reference to the version of the node instead of on the node itself 044 JCRResource resource = (JCRResource) _ametysObjectResolver.resolveById(resourceId); 045 activity.setValue(FILE_DATA_NAME, new ResourceReference(resourceId, resourceName, resourceOldName, resource.getMimeType(), null)); 046 } 047}