mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
ensure cache times are used for all types of requests
This commit is contained in:
1
src/app/core/cache/object-cache.service.ts
vendored
1
src/app/core/cache/object-cache.service.ts
vendored
@@ -261,6 +261,7 @@ export class ObjectCacheService {
|
|||||||
const timeOutdated = entry.timeAdded + entry.msToLive;
|
const timeOutdated = entry.timeAdded + entry.msToLive;
|
||||||
const isOutDated = new Date().getTime() > timeOutdated;
|
const isOutDated = new Date().getTime() > timeOutdated;
|
||||||
if (isOutDated) {
|
if (isOutDated) {
|
||||||
|
console.log('removing', entry.data._links.self.href);
|
||||||
this.store.dispatch(new RemoveFromObjectCacheAction(entry.data._links.self.href));
|
this.store.dispatch(new RemoveFromObjectCacheAction(entry.data._links.self.href));
|
||||||
}
|
}
|
||||||
return !isOutDated;
|
return !isOutDated;
|
||||||
|
@@ -316,7 +316,9 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
).subscribe((href: string) => {
|
).subscribe((href: string) => {
|
||||||
this.requestService.removeByHrefSubstring(href);
|
this.requestService.removeByHrefSubstring(href);
|
||||||
const request = new FindListRequest(requestId, href, options);
|
const request = new FindListRequest(requestId, href, options);
|
||||||
request.responseMsToLive = 10 * 1000;
|
if (hasValue(this.responseMsToLive)) {
|
||||||
|
request.responseMsToLive = this.responseMsToLive;
|
||||||
|
}
|
||||||
this.requestService.configure(request);
|
this.requestService.configure(request);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -343,6 +345,9 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
find((href: string) => hasValue(href)),
|
find((href: string) => hasValue(href)),
|
||||||
map((href: string) => {
|
map((href: string) => {
|
||||||
const request = new PatchRequest(requestId, href, operations);
|
const request = new PatchRequest(requestId, href, operations);
|
||||||
|
if (hasValue(this.responseMsToLive)) {
|
||||||
|
request.responseMsToLive = this.responseMsToLive;
|
||||||
|
}
|
||||||
this.requestService.configure(request);
|
this.requestService.configure(request);
|
||||||
})
|
})
|
||||||
).subscribe();
|
).subscribe();
|
||||||
@@ -362,6 +367,11 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
const requestId = this.requestService.generateRequestId();
|
const requestId = this.requestService.generateRequestId();
|
||||||
const serializedObject = new DSpaceSerializer(object.constructor as GenericConstructor<{}>).serialize(object);
|
const serializedObject = new DSpaceSerializer(object.constructor as GenericConstructor<{}>).serialize(object);
|
||||||
const request = new PutRequest(requestId, object._links.self.href, serializedObject);
|
const request = new PutRequest(requestId, object._links.self.href, serializedObject);
|
||||||
|
|
||||||
|
if (hasValue(this.responseMsToLive)) {
|
||||||
|
request.responseMsToLive = this.responseMsToLive;
|
||||||
|
}
|
||||||
|
|
||||||
this.requestService.configure(request);
|
this.requestService.configure(request);
|
||||||
|
|
||||||
return this.requestService.getByUUID(requestId).pipe(
|
return this.requestService.getByUUID(requestId).pipe(
|
||||||
@@ -411,7 +421,13 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
|
|
||||||
const request$ = endpoint$.pipe(
|
const request$ = endpoint$.pipe(
|
||||||
take(1),
|
take(1),
|
||||||
map((endpoint: string) => new CreateRequest(requestId, endpoint, JSON.stringify(serializedDso)))
|
map((endpoint: string) => {
|
||||||
|
const request = new CreateRequest(requestId, endpoint, JSON.stringify(serializedDso));
|
||||||
|
if (hasValue(this.responseMsToLive)) {
|
||||||
|
request.responseMsToLive = this.responseMsToLive;
|
||||||
|
}
|
||||||
|
return request
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
// Execute the post request
|
// Execute the post request
|
||||||
@@ -460,7 +476,13 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
|
|
||||||
const request$ = endpoint$.pipe(
|
const request$ = endpoint$.pipe(
|
||||||
take(1),
|
take(1),
|
||||||
map((endpoint: string) => new CreateRequest(requestId, endpoint, JSON.stringify(serializedDso)))
|
map((endpoint: string) => {
|
||||||
|
const request = new CreateRequest(requestId, endpoint, JSON.stringify(serializedDso));
|
||||||
|
if (hasValue(this.responseMsToLive)) {
|
||||||
|
request.responseMsToLive = this.responseMsToLive;
|
||||||
|
}
|
||||||
|
return request
|
||||||
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
// Execute the post request
|
// Execute the post request
|
||||||
@@ -508,6 +530,9 @@ export abstract class DataService<T extends CacheableObject> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
const request = new DeleteByIDRequest(requestId, href, dsoID);
|
const request = new DeleteByIDRequest(requestId, href, dsoID);
|
||||||
|
if (hasValue(this.responseMsToLive)) {
|
||||||
|
request.responseMsToLive = this.responseMsToLive;
|
||||||
|
}
|
||||||
this.requestService.configure(request);
|
this.requestService.configure(request);
|
||||||
})
|
})
|
||||||
).subscribe();
|
).subscribe();
|
||||||
|
@@ -52,7 +52,13 @@ import { DefaultChangeAnalyzer } from './default-change-analyzer.service';
|
|||||||
import { ItemDataService } from './item-data.service';
|
import { ItemDataService } from './item-data.service';
|
||||||
import { PaginatedList } from './paginated-list';
|
import { PaginatedList } from './paginated-list';
|
||||||
import { RemoteData, RemoteDataState } from './remote-data';
|
import { RemoteData, RemoteDataState } from './remote-data';
|
||||||
import { DeleteRequest, FindListOptions, PostRequest, RestRequest } from './request.models';
|
import {
|
||||||
|
DeleteRequest,
|
||||||
|
FindListOptions,
|
||||||
|
PostRequest,
|
||||||
|
RestRequest,
|
||||||
|
FindByIDRequest
|
||||||
|
} from './request.models';
|
||||||
import { RequestService } from './request.service';
|
import { RequestService } from './request.service';
|
||||||
import has = Reflect.has;
|
import has = Reflect.has;
|
||||||
|
|
||||||
@@ -86,6 +92,7 @@ const compareItemsByUUID = (itemCheck: Item) =>
|
|||||||
@dataService(RELATIONSHIP)
|
@dataService(RELATIONSHIP)
|
||||||
export class RelationshipService extends DataService<Relationship> {
|
export class RelationshipService extends DataService<Relationship> {
|
||||||
protected linkPath = 'relationships';
|
protected linkPath = 'relationships';
|
||||||
|
protected responseMsToLive = 15 * 60 * 1000;
|
||||||
|
|
||||||
constructor(protected itemService: ItemDataService,
|
constructor(protected itemService: ItemDataService,
|
||||||
protected requestService: RequestService,
|
protected requestService: RequestService,
|
||||||
|
@@ -47,6 +47,7 @@ import { Store } from '@ngrx/store';
|
|||||||
import { SubmissionService } from '../../../../../../submission/submission.service';
|
import { SubmissionService } from '../../../../../../submission/submission.service';
|
||||||
import { AppState } from '../../../../../../app.reducer';
|
import { AppState } from '../../../../../../app.reducer';
|
||||||
import { followLink } from '../../../../../utils/follow-link-config.model';
|
import { followLink } from '../../../../../utils/follow-link-config.model';
|
||||||
|
import { ObjectCacheService } from '../../../../../../core/cache/object-cache.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-dynamic-form-array',
|
selector: 'ds-dynamic-form-array',
|
||||||
@@ -74,6 +75,7 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple
|
|||||||
|
|
||||||
constructor(protected layoutService: DynamicFormLayoutService,
|
constructor(protected layoutService: DynamicFormLayoutService,
|
||||||
protected validationService: DynamicFormValidationService,
|
protected validationService: DynamicFormValidationService,
|
||||||
|
protected objectCacheService: ObjectCacheService,
|
||||||
protected relationshipService: RelationshipService,
|
protected relationshipService: RelationshipService,
|
||||||
protected changeDetectorRef: ChangeDetectorRef,
|
protected changeDetectorRef: ChangeDetectorRef,
|
||||||
protected submissionObjectService: SubmissionObjectDataService,
|
protected submissionObjectService: SubmissionObjectDataService,
|
||||||
@@ -183,7 +185,6 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple
|
|||||||
let hasMetadataField = false;
|
let hasMetadataField = false;
|
||||||
this.reorderables.forEach((reorderable: Reorderable, index: number) => {
|
this.reorderables.forEach((reorderable: Reorderable, index: number) => {
|
||||||
if (reorderable.hasMoved) {
|
if (reorderable.hasMoved) {
|
||||||
console.log('reorderable moved', reorderable);
|
|
||||||
const prevIndex = reorderable.oldIndex;
|
const prevIndex = reorderable.oldIndex;
|
||||||
const updatedReorderable = reorderable.update().pipe(take(1));
|
const updatedReorderable = reorderable.update().pipe(take(1));
|
||||||
updatedReorderables.push(updatedReorderable);
|
updatedReorderables.push(updatedReorderable);
|
||||||
@@ -192,7 +193,6 @@ export class DsDynamicFormArrayComponent extends DynamicFormArrayComponent imple
|
|||||||
updatedReorderable.subscribe((v) => {
|
updatedReorderable.subscribe((v) => {
|
||||||
const reoMD = reorderable as ReorderableFormFieldMetadataValue;
|
const reoMD = reorderable as ReorderableFormFieldMetadataValue;
|
||||||
reoMD.model.value = reoMD.metadataValue;
|
reoMD.model.value = reoMD.metadataValue;
|
||||||
console.log('reoMD', reoMD);
|
|
||||||
this.onChange({
|
this.onChange({
|
||||||
$event: { previousIndex: prevIndex },
|
$event: { previousIndex: prevIndex },
|
||||||
context: { index },
|
context: { index },
|
||||||
|
Reference in New Issue
Block a user