diff --git a/gulp/copy.js b/gulp/copy.js
index 760938ccd..e88d7f264 100644
--- a/gulp/copy.js
+++ b/gulp/copy.js
@@ -20,7 +20,8 @@ module.exports = {
swagger: swagger,
images: images,
jstree: jstree,
- ace: ace
+ ace: ace,
+ customjs: customjs
}
//var yorc = require('../.yo-rc.json')['generator-jhipster'];
@@ -80,6 +81,12 @@ function ace() {
.pipe(gulp.dest(config.dist + 'content/js/ace/'));
}
+function customjs() {
+ return gulp.src(config.app + 'content/js/*.js')
+ .pipe(plumber({errorHandler: handleErrors}))
+ .pipe(gulp.dest(config.dist + 'content/js/'));
+}
+
function common() {
return gulp.src([config.app + 'robots.txt', config.app + 'favicon.ico', config.app + '.htaccess'], { dot: true })
.pipe(plumber({errorHandler: handleErrors}))
diff --git a/gulpfile.js b/gulpfile.js
index 3a08cb038..5536f9737 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -30,7 +30,7 @@ gulp.task('clean', function () {
return del([config.dist], { dot: true });
});
-gulp.task('copy', ['copy:i18n', 'copy:fonts', 'copy:common', 'copy:jstree', 'copy:ace']);
+gulp.task('copy', ['copy:i18n', 'copy:fonts', 'copy:common', 'copy:jstree', 'copy:ace', 'copy:customjs']);
gulp.task('copy:i18n', copy.i18n);
@@ -47,6 +47,8 @@ gulp.task('copy:images', copy.images);
// custom Martin
gulp.task('copy:jstree', copy.jstree);
gulp.task('copy:ace', copy.ace);
+gulp.task('copy:customjs', copy.customjs);
+
gulp.task('images', function () {
return gulp.src(config.app + 'content/images/**')
diff --git a/src/main/java/it/cnr/si/config/ACERestConfiguration.java b/src/main/java/it/cnr/si/config/ACERestConfiguration.java
new file mode 100644
index 000000000..995c980c5
--- /dev/null
+++ b/src/main/java/it/cnr/si/config/ACERestConfiguration.java
@@ -0,0 +1,63 @@
+package it.cnr.si.config;
+
+
+import feign.Feign;
+import feign.form.FormEncoder;
+import feign.gson.GsonDecoder;
+import feign.gson.GsonEncoder;
+import it.cnr.si.flows.ng.service.AceAuthService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.bind.RelaxedPropertyResolver;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+import org.springframework.core.env.Environment;
+import org.springframework.security.oauth2.client.OAuth2ClientContext;
+import org.springframework.security.oauth2.client.OAuth2RestTemplate;
+import org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails;
+import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordResourceDetails;
+import org.springframework.security.oauth2.common.AuthenticationScheme;
+import org.springframework.security.oauth2.config.annotation.web.configuration.EnableOAuth2Client;
+import org.springframework.security.oauth2.config.annotation.web.configuration.OAuth2ClientConfiguration;
+
+import javax.inject.Inject;
+import java.util.List;
+
+//@Profile("cnr")
+//@Configuration
+//@EnableOAuth2Client
+public class ACERestConfiguration {
+
+ @Inject
+ private OAuth2ClientContext oauth2Context;
+
+ @Value("${spring.ace.url}")
+ private String aceUrl;
+ @Value("${spring.ace.password}")
+ private String acePassword;
+ @Value("${spring.ace.username}")
+ private String aceUsername;
+
+ @Bean(name ="aceRestTemplate")
+ public OAuth2RestTemplate aceRestTemplate() {
+
+ final AceAuthService service = Feign.builder()
+ .decoder(new GsonDecoder())
+ .encoder(new FormEncoder(new GsonEncoder()))
+ .target(AceAuthService.class, aceUrl + "api");
+
+ service.getToken(aceUsername, acePassword);
+
+ ResourceOwnerPasswordResourceDetails details = new ResourceOwnerPasswordResourceDetails();
+ details.setPassword(acePassword);
+ details.setUsername(aceUsername);
+ details.setAccessTokenUri(aceUrl);
+ details.setTokenName("ace_token");
+
+ OAuth2RestTemplate rt = new OAuth2RestTemplate(details);
+ return rt;
+ }
+}
diff --git a/src/main/java/it/cnr/si/flows/ng/resource/FlowsAttachmentResource.java b/src/main/java/it/cnr/si/flows/ng/resource/FlowsAttachmentResource.java
index 2a60340cf..9d44d15d5 100644
--- a/src/main/java/it/cnr/si/flows/ng/resource/FlowsAttachmentResource.java
+++ b/src/main/java/it/cnr/si/flows/ng/resource/FlowsAttachmentResource.java
@@ -33,6 +33,7 @@
import java.util.stream.Collectors;
import static it.cnr.si.flows.ng.utils.Enum.Azione.Aggiornamento;
+import static it.cnr.si.flows.ng.utils.Enum.Azione.Caricamento;
@Controller
@RequestMapping("api/attachments")
@@ -162,7 +163,14 @@ public void setAttachment(@PathVariable("processInstanceId") String processInsta
FlowsAttachment attachment = runtimeService.getVariable(processInstanceId, attachmentName, FlowsAttachment.class);
- attachment.setAzione(Aggiornamento);
+ if (attachment != null) {
+ attachment.setAzione(Aggiornamento);
+ } else {
+ attachment = new FlowsAttachment();
+ attachment.setName(attachmentName);
+ attachment.setAzione(Caricamento);
+ }
+
attachment.setBytes(file.getBytes());
attachment.setFilename(file.getOriginalFilename());
attachment.setMimetype(file.getContentType());
diff --git a/src/main/java/it/cnr/si/flows/ng/service/Ace.java b/src/main/java/it/cnr/si/flows/ng/service/Ace.java
index 918a2c087..3ddcef660 100644
--- a/src/main/java/it/cnr/si/flows/ng/service/Ace.java
+++ b/src/main/java/it/cnr/si/flows/ng/service/Ace.java
@@ -67,7 +67,7 @@ public interface Ace {
@RequestLine("GET api/ace/v1/ruolo/{sigla}")
RuoloWebDto ruoloBySigla(@Param("sigla") String sigla);
- @RequestLine("GET api/ace//v1/entitaorganizzativa/{id}")
+ @RequestLine("GET api/ace/v1/entitaorganizzativa/{id}")
EntitaOrganizzativaWebDto entitaOrganizzativaById(@Param("id") int id);
@RequestLine("GET api/ace/v1/entitaorganizzativa?term={term}")
diff --git a/src/main/webapp/app/components/attachments/addattachment.modal.controller.js b/src/main/webapp/app/components/attachments/addattachment.modal.controller.js
new file mode 100644
index 000000000..a9235f63e
--- /dev/null
+++ b/src/main/webapp/app/components/attachments/addattachment.modal.controller.js
@@ -0,0 +1,32 @@
+(function() {
+ 'use strict';
+
+ angular.module('sprintApp')
+ .controller('AddAttachmentModalController', AddAttachmentModalController);
+
+
+ AddAttachmentModalController.$inject = ['$scope', '$uibModalInstance', 'dataService', 'processInstanceId', 'Upload', 'AlertService', '$log'];
+
+ function AddAttachmentModalController ($scope, $uibModalInstance, dataService, processInstanceId, Upload, AlertService, $log) {
+
+ var vm = this;
+ vm.data = {processInstanceId: processInstanceId};
+ $scope.data = {};
+
+ $scope.submitDocumento = function(file) {
+
+ Upload.upload({
+ url: 'api/attachments/'+ processInstanceId +'/'+ 'nuovoDocumento' +'/data',
+ data: $scope.data,
+ }).then(function (response) {
+ $scope.loadAttachments();
+ $uibModalInstance.close();
+ AlertService.success("Richiesta completata con successo");
+
+ }, function (err) {
+ $log.error(err);
+ AlertService.error("Richiesta non riuscita
"+ err.data.message);
+ });
+ }
+ }
+})();
\ No newline at end of file
diff --git a/src/main/webapp/app/components/attachments/addattachment.modal.html b/src/main/webapp/app/components/attachments/addattachment.modal.html
new file mode 100644
index 000000000..3cd985fb0
--- /dev/null
+++ b/src/main/webapp/app/components/attachments/addattachment.modal.html
@@ -0,0 +1,23 @@
+