2 * Copyright (C) 2007-2012 Argeo GmbH
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org
.argeo
.slc
.lib
.detached
;
18 import java
.util
.Properties
;
19 import java
.util
.UUID
;
21 import org
.apache
.commons
.logging
.Log
;
22 import org
.apache
.commons
.logging
.LogFactory
;
23 import org
.argeo
.slc
.SlcException
;
24 import org
.argeo
.slc
.detached
.DetachedAnswer
;
25 import org
.argeo
.slc
.detached
.DetachedClient
;
26 import org
.argeo
.slc
.detached
.DetachedRequest
;
28 public class DetachedAdminTask
implements Runnable
{
29 private final static Log log
= LogFactory
.getLog(DetachedAdminTask
.class);
31 private String action
;
32 private DetachedClient client
;
33 private Properties properties
;
36 // Prepare and send request
37 DetachedRequest request
= new DetachedRequest(UUID
.randomUUID()
39 request
.setRef(action
);
41 if (properties
!= null) {
42 request
.setProperties(properties
);
46 client
.sendRequest(request
);
47 DetachedAnswer answer
= client
.receiveAnswer();
48 if (answer
.getStatus() == DetachedAnswer
.ERROR
)
49 throw new SlcException("Error when executing request "
50 + answer
.getUuid() + ": " + answer
.getLog());
52 log
.info("Admin answer: " + answer
.getLog());
53 } catch (Exception e
) {
54 throw new SlcException("Could not send request.", e
);
58 public void setAction(String action
) {
62 public void setClient(DetachedClient detachedClient
) {
63 this.client
= detachedClient
;
66 public void setProperties(Properties properties
) {
67 this.properties
= properties
;